PyTorch implementation of Graph Convolutional Networks (GCNs) based on (Kipf & Welling, ICLR 2017)
The Graph Convolution layer module is implemented in gc_layer.py
file as GraphConvolution
class. It follows the official PyTorch layer module interface.
This module computes the following expression as part of message passing mechanism:
where the D⁻¹/²ÃD⁻¹/²
part is received as an input argument to the forward
method in sparse matrix tensor format and the node features H
is also recieved as an in*put argument to the forward
method.
The main Graph Convolutional Network module is implemented in gcn.py
file as GCN
class. The forward
method performs a full two-layer GCN operation on the given input features based on the paper as shown below:
The module requires the number of input features (nfeat
), number of hidden features (nhid
), number of output classes (nclass
), dropout rate (dropout
), and PyTorch device object (device
) as input args for instantiation.
The implemented GCN is tested on the KarateClub toy dataset from PyG in the test.ipynb
notebook.