README.md 5.05 KB
Newer Older
1
# DGL examples for ogbn-arxiv
2

3
4
DGL implementation of GCN and GAT for [ogbn-arxiv](https://ogb.stanford.edu/docs/nodeprop/). Using some of the techniques from *Bag of Tricks for Node Classification with Graph Neural Networks* ([https://arxiv.org/abs/2103.13355](https://arxiv.org/abs/2103.13355)).

5
6
Requires DGL 0.5 or later versions.

7
8
### GCN

9
For the best score, run `gcn.py` with `--use-linear` and `--use-labels` enabled and you should directly see the result.
10

11
12
13
```bash
python3 gcn.py --use-linear --use-labels
```
14

15
16
### GAT

17
18
19
20
21
22
23
For the score of `GAT(norm. adj.)+labels`, run the following command and you should directly see the result.

```bash
python3 gat.py --use-norm --use-labels --no-attn-dst --edge-drop=0.1 --input-drop=0.1
```

For the score of `GAT(norm. adj.)+label reuse`, run the following command and you should directly see the result.
24
25

```bash
26
27
28
29
30
31
32
33
python3 gat.py --use-norm --use-labels --n-label-iters=1 --no-attn-dst --edge-drop=0.3 --input-drop=0.25
```

For the score of `GAT(norm. adj.)+label reuse+C&S`, run the following command and you should directly see the result.

```bash
python3 gat.py --use-norm --use-labels --n-label-iters=1 --no-attn-dst --edge-drop=0.3 --input-drop=0.25 --save-pred
python3 correct_and_smooth.py --use-norm
34
35
36
37
38
```

## Usage & Options

### GCN
39
40

```
41
42
usage: GCN on OGBN-Arxiv [-h] [--cpu] [--gpu GPU] [--n-runs N_RUNS] [--n-epochs N_EPOCHS] [--use-labels] [--use-linear] [--lr LR] [--n-layers N_LAYERS] [--n-hidden N_HIDDEN]
                         [--dropout DROPOUT] [--wd WD] [--log-every LOG_EVERY] [--plot-curves]
43
44
45

optional arguments:
  -h, --help            show this help message and exit
46
47
  --cpu                 CPU mode. This option overrides --gpu. (default: False)
  --gpu GPU             GPU device ID. (default: 0)
48
49
  --n-runs N_RUNS       running times (default: 10)
  --n-epochs N_EPOCHS   number of epochs (default: 1000)
50
51
  --use-labels          Use labels in the training set as input features. (default: False)
  --use-linear          Use linear layer. (default: False)
52
53
54
55
56
  --lr LR               learning rate (default: 0.005)
  --n-layers N_LAYERS   number of layers (default: 3)
  --n-hidden N_HIDDEN   number of hidden units (default: 256)
  --dropout DROPOUT     dropout rate (default: 0.75)
  --wd WD               weight decay (default: 0)
57
  --log-every LOG_EVERY
58
59
                        log every LOG_EVERY epochs (default: 20)
  --plot-curves         plot learning curves (default: False)
60
61
```

62
63
64
### GAT

```
65
66
67
usage: GAT on OGBN-Arxiv [-h] [--cpu] [--gpu GPU] [--n-runs N_RUNS] [--n-epochs N_EPOCHS] [--use-labels] [--n-label-iters N_LABEL_ITERS] [--no-attn-dst]
                         [--use-norm] [--lr LR] [--n-layers N_LAYERS] [--n-heads N_HEADS] [--n-hidden N_HIDDEN] [--dropout DROPOUT] [--input-drop INPUT_DROP]
                         [--attn-drop ATTN_DROP] [--edge-drop EDGE_DROP] [--wd WD] [--log-every LOG_EVERY] [--plot-curves]
68
69
70
71
72

optional arguments:
  -h, --help            show this help message and exit
  --cpu                 CPU mode. This option overrides --gpu. (default: False)
  --gpu GPU             GPU device ID. (default: 0)
73
74
  --n-runs N_RUNS       running times (default: 10)
  --n-epochs N_EPOCHS   number of epochs (default: 2000)
75
  --use-labels          Use labels in the training set as input features. (default: False)
76
77
78
  --n-label-iters N_LABEL_ITERS
                        number of label iterations (default: 0)
  --no-attn-dst         Don't use attn_dst. (default: False)
79
  --use-norm            Use symmetrically normalized adjacency matrix. (default: False)
80
81
82
83
84
85
86
87
88
89
90
91
  --lr LR               learning rate (default: 0.002)
  --n-layers N_LAYERS   number of layers (default: 3)
  --n-heads N_HEADS     number of heads (default: 3)
  --n-hidden N_HIDDEN   number of hidden units (default: 250)
  --dropout DROPOUT     dropout rate (default: 0.75)
  --input-drop INPUT_DROP
                        input drop rate (default: 0.1)
  --attn-drop ATTN_DROP
                        attention dropout rate (default: 0.0)
  --edge-drop EDGE_DROP
                        edge drop rate (default: 0.0)
  --wd WD               weight decay (default: 0)
92
  --log-every LOG_EVERY
93
94
                        log every LOG_EVERY epochs (default: 20)
  --plot-curves         plot learning curves (default: False)
95
96
```

97
98
## Results

99
100
101
102
103
104
105
106
107
108
109
Here are the results over at least 10 runs.

|             Method              | Validation Accuracy |  Test Accuracy  | #Parameters |
|:-------------------------------:|:-------------------:|:---------------:|:-----------:|
|               GCN               |   0.7361 ± 0.0009   | 0.7246 ± 0.0021 |   109,608   |
|           GCN+linear            |   0.7397 ± 0.0010   | 0.7270 ± 0.0016 |   218,152   |
|           GCN+labels            |   0.7399 ± 0.0008   | 0.7259 ± 0.0006 |   119,848   |
|        GCN+linear+labels        |   0.7442 ± 0.0012   | 0.7306 ± 0.0024 |   238,632   |
|     GAT(norm. adj.)+labels      |   0.7508 ± 0.0009   | 0.7366 ± 0.0011 |  1,441,580  |
|   GAT(norm. adj.)+label reuse   |   0.7516 ± 0.0008   | 0.7391 ± 0.0012 |  1,441,580  |
| GAT(norm. adj.)+label reuse+C&S |   0.7519 ± 0.0008   | 0.7395 ± 0.0012 |  1,441,580  |