"vscode:/vscode.git/clone" did not exist on "b7e2f800ac1f5056f8789a2cb7b851a11df36433"
README.md 2.93 KB
Newer Older
Lingfan Yu's avatar
Lingfan Yu committed
1
2
# Relational-GCN

Gan Quan's avatar
Gan Quan committed
3
4
5
6
* Paper: [https://arxiv.org/abs/1703.06103](https://arxiv.org/abs/1703.06103)
* 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
8
9
10
11
### Dependencies
* PyTorch 0.4.1+
* requests
* rdflib
* pandas
Lingfan Yu's avatar
Lingfan Yu committed
12

13
14
15
```
pip install requests torch rdflib pandas
```
Lingfan Yu's avatar
Lingfan Yu committed
16
17
18
19

Example code was tested with rdflib 4.2.2 and pandas 0.23.4

### Entity Classification
Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
20
AIFB: accuracy 96.29% (3 runs, DGL), 95.83% (paper)
Lingfan Yu's avatar
Lingfan Yu committed
21
22
23
24
```
python3 entity_classify.py -d aifb --testing --gpu 0
```

Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
25
MUTAG: accuracy 70.59% (3 runs, DGL), 73.23% (paper)
Lingfan Yu's avatar
Lingfan Yu committed
26
27
28
29
```
python3 entity_classify.py -d mutag --l2norm 5e-4 --n-bases 30 --testing --gpu 0
```

Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
30
BGS: accuracy 93.10% (3 runs, DGL), 83.10% (paper)
Lingfan Yu's avatar
Lingfan Yu committed
31
```
32
python3 entity_classify.py -d bgs --l2norm 5e-4 --n-bases 40 --testing --gpu 0
Lingfan Yu's avatar
Lingfan Yu committed
33
34
```

Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
35
AM: accuracy 89.22% (3 runs, DGL), 89.29% (paper)
36
37
38
39
```
python3 entity_classify.py -d am --n-bases=40 --n-hidden=10 --l2norm=5e-4 --testing
```

40
### Entity Classification with minibatch
Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
41
AIFB: accuracy avg(5 runs) 90.00%, best 94.44% (DGL)
42
```
43
python3 entity_classify_mp.py -d aifb --testing --gpu 0 --fanout='20,20' --batch-size 128
44
45
```

Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
46
MUTAG: accuracy avg(10 runs) 62.94%, best 72.06% (DGL)
47
```
xiang song(charlie.song)'s avatar
xiang song(charlie.song) committed
48
python3 entity_classify_mp.py -d mutag --l2norm 5e-4 --n-bases 30 --testing --gpu 0 --batch-size 64 --fanout "-1, -1" --use-self-loop --dgl-sparse --n-epochs 20 --sparse-lr 0.01 --dropout 0.5
49
50
```

Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
51
BGS: accuracy avg(5 runs) 78.62%, best 86.21% (DGL)
52
```
xiang song(charlie.song)'s avatar
xiang song(charlie.song) committed
53
python3 entity_classify_mp.py -d bgs --l2norm 5e-4 --n-bases 40 --testing --gpu 0 --fanout "-1, -1"  --n-epochs=16 --batch-size=16 --dgl-sparse  --lr 0.01 --sparse-lr 0.05 --dropout 0.3
54
55
```

Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
56
AM: accuracy avg(5 runs) 87.37%, best 89.9% (DGL)
57
```
58
python3 entity_classify_mp.py -d am --l2norm 5e-4 --n-bases 40 --testing  --gpu 0 --fanout '35,35' --batch-size 64 --n-hidden 16 --use-self-loop --n-epochs=20 --dgl-sparse --lr 0.01  --sparse-lr 0.02 --dropout 0.7
59
60
61
62
63
```

### Entity Classification on OGBN-MAG
Test-bd: P3-8xlarge

64
OGBN-MAG accuracy 45.5 (3 runs)
65
```
66
python3 entity_classify_mp.py -d ogbn-mag --testing --fanout='30,30' --batch-size 1024 --n-hidden 128 --lr 0.01 --num-worker 4 --eval-batch-size 8 --low-mem --gpu 0,1,2,3 --dropout 0.7 --use-self-loop --n-bases 2 --n-epochs 3 --node-feats --dgl-sparse --sparse-lr 0.08
67
68
```

69
OGBN-MAG without node-feats 42.79
70
```
71
python3 entity_classify_mp.py -d ogbn-mag --testing --fanout='30,30' --batch-size 1024 --n-hidden 128 --lr 0.01 --num-worker 4 --eval-batch-size 8 --low-mem --gpu 0,1,2,3 --dropout 0.7 --use-self-loop --n-bases 2 --n-epochs 3 --dgl-sparse --sparse-lr 0.08
72
73
74
75
```

Test-bd: P2-8xlarge

Lingfan Yu's avatar
Lingfan Yu committed
76
### Link Prediction
77
FB15k-237: MRR 0.151 (DGL), 0.158 (paper)
Lingfan Yu's avatar
Lingfan Yu committed
78
```
79
python3 link_predict.py -d FB15k-237 --gpu 0 --eval-protocol raw
80
81
82
```
FB15k-237: Filtered-MRR 0.2044
```
83
python3 link_predict.py -d FB15k-237 --gpu 0 --eval-protocol filtered
Lingfan Yu's avatar
Lingfan Yu committed
84
```