Given node and relation embeddings, CompGCN performs a composition operation φ(·) over each edge in the neighborhood of a central node (e.g. Christopher Nolan above). The composed embeddings are then convolved with specific filters WO and WI for original and inverse relations respectively. We omit self-loop in the diagram for clarity. The message from all the neighbors are then aggregated to get an updated embedding of the central node. Also, the relation embeddings are transformed using a separate weight matrix. Please refer to the paper for details.
We evaluated the CompGCN repository with the following configurations.
pip install -r requirements_old.txt
.
pip install --no-index torch_scatter==2.0.4 -f https://data.pyg.org/whl/torch-1.4.0+cpu.html
pip install torch==1.4.0 --extra-index-url https://download.pytorch.org/whl/cpu
pip install -r requirements_old.txt
.
pip install --no-index torch_scatter==2.0.4 -f https://data.pyg.org/whl/torch-1.4.0%2Bcu101.html
For pyTorch 1.4 you need to manually search to correct version here, because the official installation methods are broken [1]. For example here we are installing pyTorch 1.4 for the Windows platform on a mobile chip:
pip install https://download.pytorch.org/whl/cu101/torch-1.4.0-cp37-cp37m-win_amd64.whl
pip install -r requirements.txt
.
pip install torch==1.13.1 --extra-index-url https://download.pytorch.org/whl/cu117
pip install torch-scatter==2.1.0 -f https://data.pyg.org/whl/torch-1.13.0+cu117.html
pip install -r requirements.txt
.
pip install torch==1.13.1 --extra-index-url https://download.pytorch.org/whl/cpu
pip install torch-scatter==2.1.0 -f https://data.pyg.org/whl/torch-1.13.1+cpu.html
The script extractLossAndMRR.sh
takes the file name as argument. See the example below
sh extractLossAndMRR.sh -f=TransE_Corr_codex_s_with_GCN_log
This will create a csv File called csv_TransE_Corr_codex_s_with_GCN_log
which contains the results.
Keep in mind, that the parameter only accepts filenames, not paths, so the log must be in the same folder as the script.
data
directory. Execute ./preprocess.sh
for extracting the dataset and setting up the folder hierarchy for experiments.
Commands for reproducing the reported results on link prediction:
##### with TransE Score Function
# CompGCN (Composition: Subtraction)
python run.py -score_func transe -opn sub -gamma 9 -hid_drop 0.1 -init_dim 200
# CompGCN (Composition: Multiplication)
python run.py -score_func transe -opn mult -gamma 9 -hid_drop 0.2 -init_dim 200
# CompGCN (Composition: Circular Correlation)
python run.py -score_func transe -opn corr -gamma 40 -hid_drop 0.1 -init_dim 200
##### with DistMult Score Function
# CompGCN (Composition: Subtraction)
python run.py -score_func distmult -opn sub -gcn_dim 150 -gcn_layer 2
# CompGCN (Composition: Multiplication)
python run.py -score_func distmult -opn mult -gcn_dim 150 -gcn_layer 2
# CompGCN (Composition: Circular Correlation)
python run.py -score_func distmult -opn corr -gcn_dim 150 -gcn_layer 2
##### with ConvE Score Function
# CompGCN (Composition: Subtraction)
python run.py -score_func conve -opn sub -ker_sz 5
# CompGCN (Composition: Multiplication)
python run.py -score_func conve -opn mult
# CompGCN (Composition: Circular Correlation)
python run.py -score_func conve -opn corr
# CompGCN (Composition: Subtraction) with disabled GNN encoder
python run.py -score_func conve -opn sub -ker_sz 5 -data codex-s -k_w 10 -k_h 10 -gcn_dim 100 -disable_gnn_encoder 1
##### CompGCN with CTKGC ScoreFunction
python run.py -score_func ctkgc -init_dim 100 -embed_dim 100 -opn sub -data codex-s
##### CompGCN with ConvKB ScoreFunction
python run.py -score_func convkb -init_dim 100 -embed_dim 100 -num_filt 3 -opn sub
##### CompGCN with Unstructured Score Function
python run.py -score_func unstructured -opn sub -gamma 9 -hid_drop 0.1 -init_dim 200
##### Overall BEST:
python run.py -name best_model -score_func conve -opn corr
#### Evaluate an already trained Model:
python run.py -name XXX -score_func conve -opn corr -evaluate
-score_func
denotes the link prediction score function -opn
is the composition operation used in CompGCN. It can take the following values:sub
for subtraction operation: Φ(e_s, e_r) = e_s - e_rmult
for multiplication operation: Φ(e_s, e_r) = e_s * e_rcorr
for circular-correlation: Φ(e_s, e_r) = e_s ★ e_r-name
is some name given for the run (used for storing model parameters)-model
is name of the model `compgcn'.-gpu
for specifying the GPU to usepython run.py -h
Please cite the following paper if you use this code in your work.
@inproceedings{
vashishth2020compositionbased,
title={Composition-based Multi-Relational Graph Convolutional Networks},
author={Shikhar Vashishth and Soumya Sanyal and Vikram Nitin and Partha Talukdar},
booktitle={International Conference on Learning Representations},
year={2020},
url={https://openreview.net/forum?id=BylA_C4tPr}
}
For any clarification, comments, or suggestions please create an issue or contact Shikhar.