Unverified Commit 4ea42e3e authored by Da Zheng's avatar Da Zheng Committed by GitHub
Browse files

fix gcn. (#469)

parent 8058f1c5
......@@ -21,6 +21,7 @@ The folder contains three implementations of GCN:
- `gcn_mp.py` uses user-defined message and reduce functions.
- `gcn_spmv.py` improves from `gcn_mp.py` by using DGL's builtin functions
so SPMV optimization could be applied.
Modify `train.py` to switch between different implementations.
The provided implementation in `gcn_concat.py` is a bit different from the
original paper for better performance, credit to @yifeim and @ZiyueHuang.
......@@ -29,7 +30,7 @@ Results
-------
Run with following (available dataset: "cora", "citeseer", "pubmed")
```bash
DGLBACKEND=mxnet python3 train.py --dataset cora --gpu 0
DGLBACKEND=mxnet python3 train.py --dataset cora --gpu 0 --self-loop
```
* cora: ~0.810 (paper: 0.815)
......
......@@ -53,7 +53,8 @@ def main(args):
# create GCN model
g = DGLGraph(data.graph)
g.add_edges(g.nodes(), g.nodes())
if args.self_loop:
g.add_edges(g.nodes(), g.nodes())
# normalization
degs = g.in_degrees().astype('float32')
norm = mx.nd.power(degs, -0.5)
......@@ -120,6 +121,9 @@ if __name__ == '__main__':
help="number of hidden gcn layers")
parser.add_argument("--weight-decay", type=float, default=5e-4,
help="Weight for L2 loss")
parser.add_argument("--self-loop", action='store_true',
help="graph self-loop (default=False)")
parser.set_defaults(self_loop=False)
args = parser.parse_args()
print(args)
......
......@@ -28,7 +28,7 @@ Results
Run with following (available dataset: "cora", "citeseer", "pubmed")
```bash
python train.py --dataset cora --gpu 0
python train.py --dataset cora --gpu 0 --self-loop
```
* cora: ~0.810 (0.79-0.83) (paper: 0.815)
......
......@@ -57,7 +57,8 @@ def main(args):
g = DGLGraph(data.graph)
n_edges = g.number_of_edges()
# add self loop
g.add_edges(g.nodes(), g.nodes())
if args.self_loop:
g.add_edges(g.nodes(), g.nodes())
# normalization
degs = g.in_degrees().float()
norm = torch.pow(degs, -0.5)
......@@ -128,6 +129,9 @@ if __name__ == '__main__':
help="number of hidden gcn layers")
parser.add_argument("--weight-decay", type=float, default=5e-4,
help="Weight for L2 loss")
parser.add_argument("--self-loop", action='store_true',
help="graph self-loop (default=False)")
parser.set_defaults(self_loop=False)
args = parser.parse_args()
print(args)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment