Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
4ea42e3e
Unverified
Commit
4ea42e3e
authored
Apr 05, 2019
by
Da Zheng
Committed by
GitHub
Apr 05, 2019
Browse files
fix gcn. (#469)
parent
8058f1c5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
4 deletions
+13
-4
examples/mxnet/gcn/README.md
examples/mxnet/gcn/README.md
+2
-1
examples/mxnet/gcn/train.py
examples/mxnet/gcn/train.py
+5
-1
examples/pytorch/gcn/README.md
examples/pytorch/gcn/README.md
+1
-1
examples/pytorch/gcn/train.py
examples/pytorch/gcn/train.py
+5
-1
No files found.
examples/mxnet/gcn/README.md
View file @
4ea42e3e
...
...
@@ -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)
...
...
examples/mxnet/gcn/train.py
View file @
4ea42e3e
...
...
@@ -53,6 +53,7 @@ def main(args):
# create GCN model
g
=
DGLGraph
(
data
.
graph
)
if
args
.
self_loop
:
g
.
add_edges
(
g
.
nodes
(),
g
.
nodes
())
# normalization
degs
=
g
.
in_degrees
().
astype
(
'float32'
)
...
...
@@ -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
)
...
...
examples/pytorch/gcn/README.md
View file @
4ea42e3e
...
...
@@ -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)
...
...
examples/pytorch/gcn/train.py
View file @
4ea42e3e
...
...
@@ -57,6 +57,7 @@ def main(args):
g
=
DGLGraph
(
data
.
graph
)
n_edges
=
g
.
number_of_edges
()
# add self loop
if
args
.
self_loop
:
g
.
add_edges
(
g
.
nodes
(),
g
.
nodes
())
# normalization
degs
=
g
.
in_degrees
().
float
()
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment