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
87a41e50
Unverified
Commit
87a41e50
authored
Jul 26, 2023
by
Andrei Ivanov
Committed by
GitHub
Jul 27, 2023
Browse files
Improving the MoNet example. (#5999)
Co-authored-by:
rudongyu
<
ru_dongyu@outlook.com
>
parent
cf5c1930
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
examples/pytorch/monet/citation.py
examples/pytorch/monet/citation.py
+13
-14
No files found.
examples/pytorch/monet/citation.py
View file @
87a41e50
...
@@ -78,7 +78,7 @@ def main(args):
...
@@ -78,7 +78,7 @@ def main(args):
val_mask
=
g
.
ndata
[
"val_mask"
]
val_mask
=
g
.
ndata
[
"val_mask"
]
test_mask
=
g
.
ndata
[
"test_mask"
]
test_mask
=
g
.
ndata
[
"test_mask"
]
in_feats
=
features
.
shape
[
1
]
in_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_la
bel
s
n_classes
=
data
.
num_
c
la
sse
s
n_edges
=
g
.
num_edges
()
n_edges
=
g
.
num_edges
()
print
(
print
(
"""----Data statistics------'
"""----Data statistics------'
...
@@ -127,7 +127,7 @@ def main(args):
...
@@ -127,7 +127,7 @@ def main(args):
)
)
# initialize graph
# initialize graph
dur
=
[]
mean
=
0
for
epoch
in
range
(
args
.
n_epochs
):
for
epoch
in
range
(
args
.
n_epochs
):
model
.
train
()
model
.
train
()
if
epoch
>=
3
:
if
epoch
>=
3
:
...
@@ -141,19 +141,18 @@ def main(args):
...
@@ -141,19 +141,18 @@ def main(args):
optimizer
.
step
()
optimizer
.
step
()
if
epoch
>=
3
:
if
epoch
>=
3
:
dur
.
append
(
time
.
time
()
-
t0
)
mean
=
(
mean
*
(
epoch
-
3
)
+
(
time
.
time
()
-
t0
)
)
/
(
epoch
-
2
)
acc
=
evaluate
(
model
,
features
,
pseudo
,
labels
,
val_mask
)
acc
=
evaluate
(
model
,
features
,
pseudo
,
labels
,
val_mask
)
print
(
print
(
"Epoch {:05d} | Time(s) {:.4f} | Loss {:.4f} | Accuracy {:.4f} | "
"Epoch {:05d} | Time(s
) {:.
4
f}
| Loss {:.4f} | Accuracy {:.4f} | "
"ETputs(KTEPS
) {:.
2
f}
"
.
format
(
"ETputs(KTEPS) {:.2f}"
.
format
(
epoch
,
epoch
,
mean
,
np
.
mean
(
dur
),
loss
.
item
(
),
loss
.
item
()
,
acc
,
acc
,
n_edges
/
mean
/
1000
,
n_edges
/
np
.
mean
(
dur
)
/
1000
,
)
)
)
)
print
()
print
()
acc
=
evaluate
(
model
,
features
,
pseudo
,
labels
,
test_mask
)
acc
=
evaluate
(
model
,
features
,
pseudo
,
labels
,
test_mask
)
...
...
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