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
885b0eae
"src/vscode:/vscode.git/clone" did not exist on "11c125667b28fc9d43ee8e9168a1ac68b3c3c1df"
Unverified
Commit
885b0eae
authored
Jul 26, 2023
by
Andrei Ivanov
Committed by
GitHub
Jul 27, 2023
Browse files
Improving the DGI example. (#6034)
parent
1f931011
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
20 deletions
+20
-20
examples/pytorch/dgi/train.py
examples/pytorch/dgi/train.py
+20
-20
No files found.
examples/pytorch/dgi/train.py
View file @
885b0eae
...
...
@@ -80,7 +80,7 @@ def main(args):
cnt_wait
=
0
best
=
1e9
best_t
=
0
dur
=
[]
mean
=
0
for
epoch
in
range
(
args
.
n_dgi_epochs
):
dgi
.
train
()
if
epoch
>=
3
:
...
...
@@ -104,12 +104,12 @@ def main(args):
break
if
epoch
>=
3
:
dur
.
append
(
time
.
time
()
-
t0
)
mean
=
(
mean
*
(
epoch
-
3
)
+
(
time
.
time
()
-
t0
)
)
/
(
epoch
-
2
)
print
(
"Epoch {:05d} | Time(s) {:.4f} | Loss {:.4f} | "
"ETputs(KTEPS) {:.2f}"
.
format
(
epoch
,
np
.
mean
(
dur
)
,
loss
.
item
(),
n_edges
/
np
.
mean
(
dur
)
/
1000
epoch
,
mean
,
loss
.
item
(),
n_edges
/
mean
/
1000
)
)
...
...
@@ -129,7 +129,7 @@ def main(args):
dgi
.
load_state_dict
(
torch
.
load
(
"best_dgi.pkl"
))
embeds
=
dgi
.
encoder
(
features
,
corrupt
=
False
)
embeds
=
embeds
.
detach
()
dur
=
[]
mean
=
0
for
epoch
in
range
(
args
.
n_classifier_epochs
):
classifier
.
train
()
if
epoch
>=
3
:
...
...
@@ -142,17 +142,17 @@ def main(args):
classifier_optimizer
.
step
()
if
epoch
>=
3
:
dur
.
append
(
time
.
time
()
-
t0
)
mean
=
(
mean
*
(
epoch
-
3
)
+
(
time
.
time
()
-
t0
)
)
/
(
epoch
-
2
)
acc
=
evaluate
(
classifier
,
embeds
,
labels
,
val_mask
)
print
(
"Epoch {:05d} | Time(s) {:.4f} | Loss {:.4f} | Accuracy {:.4f} | "
"ETputs(KTEPS) {:.2f}"
.
format
(
epoch
,
np
.
mean
(
dur
)
,
mean
,
loss
.
item
(),
acc
,
n_edges
/
np
.
mean
(
dur
)
/
1000
,
n_edges
/
mean
/
1000
,
)
)
...
...
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