DEV Community

Cover image for Spectral Embeddings Library for Knowledge Graph Embeddings
Abhilash Majumder
Abhilash Majumder

Posted on • Edited on

Spectral Embeddings Library for Knowledge Graph Embeddings

SpectralEmbeddings (https://pypi.org/project/SpectralEmbeddings/0.2) is a python package which is used to generate node embeddings from Knowledge graphs using GCN kernels and Graph Autoencoders. Variations include VanillaGCN,ChebyshevGCN and Spline GCN along with SDNE based Graph Autoencoder.
There are broadly 2 categories for Knowledge graph embeddings through this package:

  • Graph AutoEncoders: This models the first and higher order similarity measures in a graph for each node in a neighborhood. The first and second order similarity measures are created through an Autoencoder circuit which preserves the proximity loss of similarity with reconstruction loss. This model has been implemented along the lines of SDNE . These embeddings not only cover the first order dependencies but also are used to capture second order dependencies between node neighbors. The output of this AutoEncoder network has a dimension of (number of input entries,dimension of embedding space provided).

image

  • Graph Convolution Kernels: These embeddings are based on spectral graph convolution kernels which capture node representations through laplacian norm matrices. This part is based on the Graph Convolution Network paper. The GCNs are based on deep neural networks which operate on the node features and the normalized laplacian of the adjacency matrix of input graph. The GCNs are mainly used for node/subgraph classification tasks but here we are interested in capturing only the embeddings from the penultimate layer of the network. For this we create an Embedding based on Tensorflow as node features. We define that the nodes that don’t have predecessors are in layer 0. The embeddings of these nodes are just their features. To calculate the embeddings of layer k we weight the average embeddings of layer k-1 and put it into an activation function. In this kernel there are 3 variations : Vanilla GCN, Chebyshev GCN and Spline GCN embeddings

image

The repository is at the link: https://github.com/abhilash1910/SpectralEmbeddings/
Colab: https://www.kaggle.com/abhilash1910/spectralembeddings?scriptVersionId=72130689

Top comments (0)