README.md 1.69 KB
Newer Older
Lingfan Yu's avatar
Lingfan Yu committed
1
2
# Relational-GCN

Mufei Li's avatar
Mufei Li committed
3
* Paper: [Modeling Relational Data with Graph Convolutional Networks](https://arxiv.org/abs/1703.06103)
Gan Quan's avatar
Gan Quan committed
4
5
6
* Author's code for entity classification: [https://github.com/tkipf/relational-gcn](https://github.com/tkipf/relational-gcn)
* Author's code for link prediction: [https://github.com/MichSchli/RelationPrediction](https://github.com/MichSchli/RelationPrediction)

7
### Dependencies
Mufei Li's avatar
Mufei Li committed
8
* PyTorch 1.10
9
10
* rdflib
* pandas
Mufei Li's avatar
Mufei Li committed
11
12
* tqdm
* TorchMetrics
Lingfan Yu's avatar
Lingfan Yu committed
13

14
```
Mufei Li's avatar
Mufei Li committed
15
pip install rdflib pandas
16
```
Lingfan Yu's avatar
Lingfan Yu committed
17
18
19
20
21

Example code was tested with rdflib 4.2.2 and pandas 0.23.4

### Entity Classification

22
For AIFB, MUTAG, BGS and AM,
Lingfan Yu's avatar
Lingfan Yu committed
23
```
24
python entity.py -d aifb --wd 0 --gpu 0
Mufei Li's avatar
Mufei Li committed
25
26
python entity.py -d mutag --n-bases 30 --gpu 0
python entity.py -d bgs --n-bases 40 --gpu 0
27
python entity.py -d am --n-bases 40 --n-hidden 10 --gpu 0
28
29
```

30
31
### Entity Classification with minibatch

32
For AIFB, MUTAG, BGS and AM,
33
```
34
35
36
37
python entity_sample.py -d aifb --wd 0 --gpu 0 --fanout='20,20' --batch-size 128
python entity_sample.py -d mutag --n-bases 30 --gpu 0 --batch-size 64 --fanout='-1,-1' --use-self-loop --n-epochs 20 --dropout 0.5
python entity_sample.py -d bgs --n-bases 40 --gpu 0 --fanout='-1,-1'  --n-epochs=16 --batch-size=16 --dropout 0.3
python entity_sample.py -d am --n-bases 40 --gpu 0 --fanout='35,35' --batch-size 64 --n-hidden 16 --use-self-loop --n-epochs=20 --dropout 0.7
38
39
```

40
### Entity Classification on multiple GPUs
41

Mufei Li's avatar
Mufei Li committed
42
43
To use multiple GPUs, replace `entity_sample.py` with `entity_sample_multi_gpu.py` and specify
multiple GPU IDs separated by comma, e.g., `--gpu 0,1`.
44

Lingfan Yu's avatar
Lingfan Yu committed
45
### Link Prediction
46
FB15k-237 in RAW-MRR
Lingfan Yu's avatar
Lingfan Yu committed
47
```
Mufei Li's avatar
Mufei Li committed
48
python link.py --gpu 0 --eval-protocol raw
49
```
50
FB15k-237 in Filtered-MRR
51
```
Mufei Li's avatar
Mufei Li committed
52
python link.py --gpu 0 --eval-protocol filtered
Lingfan Yu's avatar
Lingfan Yu committed
53
```