项目文件夹

文件
Minjie Wang 3efb5d8ecf [NN] Add HeteroGraphConv module for cleaner module definition (#1385)
* Add HeteroGraphConv

* add custom aggregator; some docstring

* debugging

* rm print

* fix some acc bugs

* fix initialization problem in weight basis

* passed tests

* lint

* fix graphconv flag; add error message

* add mxnet heteroconv

* more fix for mx

* lint

* fix torch cuda test

* fix mx test_nn

* add exhaust test for graphconv

* add tf heteroconv

* fix comment
2020-03-27 18:47:06 +08:00
..

Relational-GCN

The preprocessing is slightly different from the author's code. We directly load and preprocess raw RDF data. For AIFB, BGS and AM, all literal nodes are pruned from the graph. For AIFB, some training/testing nodes thus become orphan and are excluded from the training/testing set. The resulting graph has fewer entities and relations. As a reference (numbers include reverse edges and relations):

Dataset #Nodes #Edges #Relations #Labeled
AIFB 8,285 58,086 90 176
AIFB-hetero 7,262 48,810 78 176
MUTAG 23,644 148,454 46 340
MUTAG-hetero 27,163 148,100 46 340
BGS 333,845 1,832,398 206 146
BGS-hetero 94,806 672,884 96 146
AM 1,666,764 11,976,642 266 1000
AM-hetero 881,680 5,668,682 96 1000

Dependencies

  • PyTorch 1.0+
  • requests
  • rdflib
pip install requests torch rdflib pandas

Example code was tested with rdflib 4.2.2 and pandas 0.23.4

Entity Classification

All experiments use one-hot encoding as featureless input. Best accuracy reported.

AIFB: accuracy 97.22% (DGL), 95.83% (paper)

python3 entity_classify.py -d aifb --testing --gpu 0

MUTAG: accuracy 73.53% (DGL), 73.23% (paper)

python3 entity_classify.py -d mutag --l2norm 5e-4 --n-bases 30 --testing --gpu 0

BGS: accuracy 93.10% (DGL), 83.10% (paper)

python3 entity_classify.py -d bgs --l2norm 5e-4 --n-bases 40 --testing --gpu 0

AM: accuracy 91.41% (DGL), 89.29% (paper)

python3 entity_classify.py -d am --l2norm 5e-4 --n-bases 40 --testing --gpu 0

Entity Classification w/ minibatch training

Accuracy numbers are reported by 10 runs.

AIFB: accuracy best=97.22% avg=93.33%

python3 entity_classify_mb.py -d aifb --testing --gpu 0 --fanout=8

MUTAG: accuracy best=76.47% avg=68.38%

python3 entity_classify_mb.py -d mutag --l2norm 5e-4 --n-bases 30 --testing --gpu 0 --batch-size=50 --fanout=8

BGS: accuracy best=96.55% avg=92.41%

python3 entity_classify_mb.py -d bgs --l2norm 5e-4 --n-bases 40 --testing --gpu 0

AM: accuracy best=90.91% avg=88.43%

python3 entity_classify_mb.py -d am --l2norm 5e-4 --n-bases 40 --testing --gpu 0

Offline Inferencing

Trained Model can be exported by providing '--model_path ' parameter to entity_classify.py. And then test_classify.py can load the saved model and do the testing offline.

AIFB:

python3 entity_classify.py -d aifb --testing --gpu 0 --model_path "aifb.pt"
python3 test_classify.py -d aifb --gpu 0 --model_path "aifb.pt"

MUTAG:

python3 entity_classify.py -d mutag --l2norm 5e-4 --n-bases 30 --testing --gpu 0 --model_path "mutag.pt"
python3 test_classify.py -d mutag --n-bases 30 --gpu 0 --model_path "mutag.pt"

BGS:

python3 entity_classify.py -d bgs --l2norm 5e-4 --n-bases 40 --testing --gpu 0 --model_path "bgs.pt"
python3 test_classify.py -d bgs --n-bases 40 --gpu 0 --model_path "bgs.pt"

AM:

python3 entity_classify.py -d am --l2norm 5e-4 --n-bases 40 --testing --gpu 0 --model_path "am.pt"
python3 test_classify.py -d am --n-bases 40 --gpu 0 --model_path "am.pt"