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
9a6b81ef
Unverified
Commit
9a6b81ef
authored
Jan 23, 2022
by
nxznm
Committed by
GitHub
Jan 23, 2022
Browse files
[Bugfix] Improve CompGCN (#3663)
Co-authored-by:
Mufei Li
<
mufeili1996@gmail.com
>
parent
d3930bab
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
examples/pytorch/compGCN/README.md
examples/pytorch/compGCN/README.md
+8
-8
examples/pytorch/compGCN/main.py
examples/pytorch/compGCN/main.py
+3
-3
examples/pytorch/compGCN/utils.py
examples/pytorch/compGCN/utils.py
+1
-1
No files found.
examples/pytorch/compGCN/README.md
View file @
9a6b81ef
...
...
@@ -9,9 +9,9 @@ This example was implemented by [zhjwy9343](https://github.com/zhjwy9343) and [K
Dependencies
----------------------
-
pytorch 1.
7.1
-
dgl 0.
6.0
-
numpy 1.
19.4
-
pytorch 1.
9.0
-
dgl 0.
7.1
-
numpy 1.
20.3
-
ordered_set 4.0.2
Dataset
...
...
@@ -67,11 +67,11 @@ Performance
| Dataset | FB15k-237 | WN18RR |
|---------| ------------------------ | ------------------------ |
| Metric | Paper / ours (dgl) | Paper / ours (dgl) |
| MRR | 0.355 / 0.34
9
| 0.479 / 0.4
71
|
| MR | 197 / 208 | 3533 / 35
50
|
| Hit@10 | 0.535 / 0.52
6
| 0.546 / 0.5
3
2 |
| Hit@3 | 0.390 / 0.38
1
| 0.494 / 0.4
80
|
| Hit@1 | 0.264 / 0.2
60
| 0.443 / 0.43
8
|
| MRR | 0.355 / 0.34
8
| 0.479 / 0.4
66
|
| MR | 197 / 208 | 3533 / 35
42
|
| Hit@10 | 0.535 / 0.52
7
| 0.546 / 0.52
5
|
| Hit@3 | 0.390 / 0.38
0
| 0.494 / 0.4
76
|
| Hit@1 | 0.264 / 0.2
59
| 0.443 / 0.43
5
|
...
...
examples/pytorch/compGCN/main.py
View file @
9a6b81ef
...
...
@@ -120,7 +120,7 @@ def main(args):
# compute loss
tr_loss
=
loss_fn
(
logits
,
label
)
train_loss
.
append
(
tr_loss
)
train_loss
.
append
(
tr_loss
.
item
()
)
# backward
optimizer
.
zero_grad
()
...
...
@@ -142,7 +142,7 @@ def main(args):
print
(
"saving model..."
)
else
:
kill_cnt
+=
1
if
kill_cnt
>
25
:
if
kill_cnt
>
100
:
print
(
'early stop.'
)
break
print
(
"In epoch {}, Train Loss: {:.4f}, Valid MRR: {:.5}
\n
, Train time: {}, Valid time: {}"
\
...
...
@@ -164,7 +164,7 @@ if __name__ == '__main__':
parser
.
add_argument
(
'--score_func'
,
dest
=
'score_func'
,
default
=
'conve'
,
help
=
'Score Function for Link prediction'
)
parser
.
add_argument
(
'--opn'
,
dest
=
'opn'
,
default
=
'ccorr'
,
help
=
'Composition Operation to be used in CompGCN'
)
parser
.
add_argument
(
'--batch'
,
dest
=
'batch_size'
,
default
=
1
28
,
type
=
int
,
help
=
'Batch size'
)
parser
.
add_argument
(
'--batch'
,
dest
=
'batch_size'
,
default
=
1
024
,
type
=
int
,
help
=
'Batch size'
)
parser
.
add_argument
(
'--gpu'
,
type
=
int
,
default
=
'0'
,
help
=
'Set GPU Ids : Eg: For CPU = -1, For Single GPU = 0'
)
parser
.
add_argument
(
'--epoch'
,
dest
=
'max_epochs'
,
type
=
int
,
default
=
500
,
help
=
'Number of epochs'
)
parser
.
add_argument
(
'--l2'
,
type
=
float
,
default
=
0.0
,
help
=
'L2 Regularization for Optimizer'
)
...
...
examples/pytorch/compGCN/utils.py
View file @
9a6b81ef
...
...
@@ -32,7 +32,7 @@ def ccorr(a, b):
-------
Tensor, having the same dimension as the input a.
"""
return
th
.
irfft
(
com_mult
(
conj
(
th
.
rfft
(
a
,
1
)),
th
.
rfft
(
b
,
1
)),
1
,
signal_sizes
=
(
a
.
shape
[
-
1
],
))
return
th
.
fft
.
irfft
n
(
th
.
conj
(
th
.
fft
.
rfft
n
(
a
,
(
-
1
)))
*
th
.
fft
.
rfft
n
(
b
,
(
-
1
)),
(
-
1
))
#identify in/out edges, compute edge norm for each and store in edata
def
in_out_norm
(
graph
):
...
...
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