A PyTorch implementation of the Relational Graph Convolutional Network (RGCN).

Overview

Torch-RGCN

Torch-RGCN is a PyTorch implementation of the RGCN, originally proposed by Schlichtkrull et al. in
Modeling Relational Data with Graph Convolutional Networks.

In our paper, we reproduce the link prediction and node classification experiments from the original paper and using our reproduction we explain the RGCN. Furthermore, we present two new configurations of the RGCN.

Getting started

Requirements:

  • Conda >= 4.8
  • Python >= 3.7

Do the following:

  1. Download all datasets: bash get_data.sh

  2. Install the dependencies inside a new virtual environment: bash setup_dependencies.sh

  3. Activate the virtual environment: conda activate torch_rgcn_venv

  4. Install the torch-RGCN module: pip install -e .

Usage

Configuration files

The hyper-parameters for the different experiments can be found in YAML files under configs. The naming convention of the files is as follows: configs/{MODEL}/{EXPERIMENT}-{DATASET}.yaml

Models

  • rgcn - Standard RGCN Model
  • c-rgcn - Compression RGCN Model
  • e-rgcn - Embedding RGCN Model

Experiments

  • lp - Link Prediction
  • nc - Node Classification

Datasets

Link Prediction

  • WN18
  • FB-Toy

Node Classification

  • AIFB
  • MUTAG
  • BGS
  • AM

Part 1: Reproduction

Link Prediction

Link Prediction Model

Original Link Prediction Implementation: https://github.com/MichSchli/RelationPrediction

To run the link prediction experiment using the RGCN model using:

python experiments/predict_links.py with configs/rgcn/lp-{DATASET}.yaml

Make sure to replace {DATASET} with one of the following dataset names: FB-toy or WN18.

Node Classification

Node Classification Model

Original Node Classification Implementation: https://github.com/tkipf/relational-gcn

To run the node classification experiment using the RGCN model using:

python experiments/classify_nodes.py with configs/rgcn/nc-{DATASET}.yaml

Make sure to replace {DATASET} with one of the following dataset names: AIFB, MUTAG, BGS or AM.

Part 2: New RGCN Configurations

Node Classification with Node Embeddings

To run the node classification experiment use:

python experiments/classify_nodes.py with configs/e-rgcn/nc-{DATASET}.yaml

Make sure to replace {DATASET} with one of the following dataset names: AIFB, MUTAG, BGS or AM.

Link Prediction Compressed Node Embeddings

c-RGCN Link Prediction Model

To run the link prediction experiment use:

python experiments/predict_links.py with configs/c-rgcn/lp-{DATASET}.yaml

Make sure to replace {DATASET} with one of the following dataset names: FB-toy, or WN18.


Dataset References

Node Classification

Link Prediction

Comments
  • work on entity alignment

    work on entity alignment

    does r-gcn works on entity alignment (existing R-GCN seems only focus on classification and link prediction)?

    If yes, May I know do you have any working code on this?

    or does this link prediction model works directly on that? Since “Links between two nodes exist” is very similar to “two nodes referring to same real-world object”

    opened by sunset1234321 1
  • Error when running the link prediction task using c-rgcn

    Error when running the link prediction task using c-rgcn

    Using the default config file present in /configs/c-rgcn/lp-WN18.yaml after changing the weight initialisation as suggested in #12, I get the following error.

    INFO - R-GCN Link Prediction  - Started
    Start training...
    ERROR - R-GCN Link Prediction  - Failed after 0:00:02!
    Traceback (most recent calls WITHOUT Sacred internals):
      File "experiments/predict_links.py", line 151, in train
        predictions, penalty = model(graph, batch_idx)
      File "/usr/local/envs/torch_rgcn_venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
        result = self.forward(*input, **kwargs)
      File "/content/drive/MyDrive/research/dr/torch-rgcn/torch_rgcn/models.py", line 235, in forward
        x = self.rgc1(graph, features=x)
      File "/usr/local/envs/torch_rgcn_venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
        result = self.forward(*input, **kwargs)
      File "/content/drive/MyDrive/research/dr/torch-rgcn/torch_rgcn/layers.py", line 550, in forward
        fw = torch.einsum('ni, rio -> rno', features, weights).contiguous()
      File "/usr/local/envs/torch_rgcn_venv/lib/python3.7/site-packages/torch/functional.py", line 201, in einsum
        return torch._C._VariableFunctions.einsum(equation, operands)
    RuntimeError: size of dimension does not match previous size, operand 1, dim 1
    

    Any help is appreciated, TIA!

    opened by Sidharth3301 1
  • GPU utilization in link prediction task is 0.

    GPU utilization in link prediction task is 0.

    As this issues mentioned, the link prediction code can't run. So I used a history commit b1b6646, it can run normally for link prediction task. But when I use the 'configs/rgcn/rp-WN18.yaml' default config files which set "use_cuda: True" , I found that the running speed is much slower than the node classification task. So I monitored the usage of gpu, I found that the utilization rate of gpu is 0. 1637132062(1) 1637132078(1)

    opened by nnnnnzy 1
  • Error when running the link prediction experiment

    Error when running the link prediction experiment

    I was able to run the node classification on all datasets, unfortunately the link prediction experiment always throws an exception, I've tried changing the configurations but no luck, below is the error:

    ...
    WARNING - root - Added new config entry: "training.use_cuda"
    WARNING - R-GCN Link Prediction  - No observers have been added to this run
    INFO - R-GCN Link Prediction  - Running command 'train'
    INFO - R-GCN Link Prediction  - Started
    ERROR - R-GCN Link Prediction  - Failed after 0:00:00!
    Traceback (most recent calls WITHOUT Sacred internals):
      File "experiments/predict_links.py", line 88, in train
        decoder_config=decoder
      File "/home/raftel/torch-rgcn/torch_rgcn/models.py", line 224, in __init__
        .__init__(nnodes, nrel, nfeat, encoder_config, decoder_config)
      File "/home/raftel/torch-rgcn/torch_rgcn/models.py", line 58, in __init__
        init(self.node_embeddings)
    TypeError: schlichtkrull_normal_() missing 1 required positional argument: 'shape'
    
    opened by raftelo 9
  • triples_plus contain original triples twice

    triples_plus contain original triples twice

    In the forward() function of the RelationalGraphConvolutionLP Layer, the generate_self_loops() function concatenates the triples and self-edges, which are then concatenated again for the triples_plus with the triples and inverse_triples. This way the triples_plus contain the original edges twice. Also, self-edges are created not only for the nodes left in the sampled (and edge-dropped) graph but for all nodes of the original graph. Is this implemented this way on purpose?

    opened by Tauboga208 0
Owner
Thiviyan Singam
PhD candidate at University of Amsterdam
Thiviyan Singam
A PyTorch implementation of "Signed Graph Convolutional Network" (ICDM 2018).

SGCN ⠀ A PyTorch implementation of Signed Graph Convolutional Network (ICDM 2018). Abstract Due to the fact much of today's data can be represented as

Benedek Rozemberczki 251 Nov 30, 2022
Code for the paper Relation Prediction as an Auxiliary Training Objective for Improving Multi-Relational Graph Representations (AKBC 2021).

Relation Prediction as an Auxiliary Training Objective for Knowledge Base Completion This repo provides the code for the paper Relation Prediction as

Facebook Research 85 Jan 2, 2023
An implementation of DeepMind's Relational Recurrent Neural Networks in PyTorch.

relational-rnn-pytorch An implementation of DeepMind's Relational Recurrent Neural Networks (Santoro et al. 2018) in PyTorch. Relational Memory Core (

Sang-gil Lee 241 Nov 18, 2022
(ICCV'21) Official PyTorch implementation of Relational Embedding for Few-Shot Classification

Relational Embedding for Few-Shot Classification (ICCV 2021) Dahyun Kang, Heeseung Kwon, Juhong Min, Minsu Cho [paper], [project hompage] We propose t

Dahyun Kang 82 Dec 24, 2022
[ICCV 2021] Official PyTorch implementation for Deep Relational Metric Learning.

Deep Relational Metric Learning This repository is the official PyTorch implementation of Deep Relational Metric Learning. Framework Datasets CUB-200-

Borui Zhang 39 Dec 10, 2022
Official Pytorch Implementation of Relational Self-Attention: What's Missing in Attention for Video Understanding

Relational Self-Attention: What's Missing in Attention for Video Understanding This repository is the official implementation of "Relational Self-Atte

mandos 43 Dec 7, 2022
[CVPR 2021 Oral] Variational Relational Point Completion Network

VRCNet: Variational Relational Point Completion Network This repository contains the PyTorch implementation of the paper: Variational Relational Point

PL 121 Dec 12, 2022
Official implementation of the paper "Steganographer Detection via a Similarity Accumulation Graph Convolutional Network"

SAGCN - Official PyTorch Implementation | Paper | Project Page This is the official implementation of the paper "Steganographer detection via a simila

ZHANG Zhi 1 Nov 26, 2021
This is the repository for the AAAI 21 paper [Contrastive and Generative Graph Convolutional Networks for Graph-based Semi-Supervised Learning].

CG3 This is the repository for the AAAI 21 paper [Contrastive and Generative Graph Convolutional Networks for Graph-based Semi-Supervised Learning]. R

null 12 Oct 28, 2022
Pytorch reimplement of the paper "A Novel Cascade Binary Tagging Framework for Relational Triple Extraction" ACL2020. The original code is written in keras.

CasRel-pytorch-reimplement Pytorch reimplement of the paper "A Novel Cascade Binary Tagging Framework for Relational Triple Extraction" ACL2020. The o

longlongman 170 Dec 1, 2022
PyTorch implementation of Graph Convolutional Networks in Feature Space for Image Deblurring and Super-resolution, IJCNN 2021.

GCResNet PyTorch implementation of Graph Convolutional Networks in Feature Space for Image Deblurring and Super-resolution, IJCNN 2021. The code will

null 11 May 19, 2022
A PyTorch implementation of "Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks" (KDD 2019).

ClusterGCN ⠀⠀ A PyTorch implementation of "Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks" (KDD 2019). A

Benedek Rozemberczki 697 Dec 27, 2022
This folder contains the implementation of the multi-relational attribute propagation algorithm.

MrAP This folder contains the implementation of the multi-relational attribute propagation algorithm. It requires the package pytorch-scatter. Please

null 6 Dec 6, 2022
ReLoss - Official implementation for paper "Relational Surrogate Loss Learning" ICLR 2022

Relational Surrogate Loss Learning (ReLoss) Official implementation for paper "R

Tao Huang 31 Nov 22, 2022
Cancer Drug Response Prediction via a Hybrid Graph Convolutional Network

DeepCDR Cancer Drug Response Prediction via a Hybrid Graph Convolutional Network This work has been accepted to ECCB2020 and was also published in the

Qiao Liu 50 Dec 18, 2022
ZSL-KG is a general-purpose zero-shot learning framework with a novel transformer graph convolutional network (TrGCN) to learn class representation from common sense knowledge graphs.

ZSL-KG is a general-purpose zero-shot learning framework with a novel transformer graph convolutional network (TrGCN) to learn class representa

Bats Research 94 Nov 21, 2022
MVGCN: a novel multi-view graph convolutional network (MVGCN) framework for link prediction in biomedical bipartite networks.

MVGCN MVGCN: a novel multi-view graph convolutional network (MVGCN) framework for link prediction in biomedical bipartite networks. Developer: Fu Hait

null 13 Dec 1, 2022
Meta graph convolutional neural network-assisted resilient swarm communications

Resilient UAV Swarm Communications with Graph Convolutional Neural Network This repository contains the source codes of Resilient UAV Swarm Communicat

null 62 Dec 6, 2022
This is an open-source toolkit for Heterogeneous Graph Neural Network(OpenHGNN) based on DGL [Deep Graph Library] and PyTorch.

This is an open-source toolkit for Heterogeneous Graph Neural Network(OpenHGNN) based on DGL [Deep Graph Library] and PyTorch.

BUPT GAMMA Lab 519 Jan 2, 2023