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
0c3b2b78
Unverified
Commit
0c3b2b78
authored
Jul 26, 2023
by
Andrei Ivanov
Committed by
GitHub
Jul 27, 2023
Browse files
Improving the HARD_GAT example (#6036)
Co-authored-by:
Hongzhi (Steve), Chen
<
chenhongzhi.nkcs@gmail.com
>
parent
885b0eae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
24 deletions
+23
-24
examples/pytorch/hardgat/train.py
examples/pytorch/hardgat/train.py
+23
-24
No files found.
examples/pytorch/hardgat/train.py
View file @
0c3b2b78
...
@@ -64,7 +64,7 @@ def main(args):
...
@@ -64,7 +64,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"
]
num_feats
=
features
.
shape
[
1
]
num_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------'
...
@@ -115,7 +115,7 @@ def main(args):
...
@@ -115,7 +115,7 @@ def main(args):
)
)
# initialize graph
# initialize graph
dur
=
[]
mean
=
0
for
epoch
in
range
(
args
.
epochs
):
for
epoch
in
range
(
args
.
epochs
):
model
.
train
()
model
.
train
()
if
epoch
>=
3
:
if
epoch
>=
3
:
...
@@ -129,8 +129,7 @@ def main(args):
...
@@ -129,8 +129,7 @@ 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
)
train_acc
=
accuracy
(
logits
[
train_mask
],
labels
[
train_mask
])
train_acc
=
accuracy
(
logits
[
train_mask
],
labels
[
train_mask
])
if
args
.
fastmode
:
if
args
.
fastmode
:
...
@@ -145,11 +144,11 @@ def main(args):
...
@@ -145,11 +144,11 @@ def main(args):
"Epoch {:05d} | Time(s) {:.4f} | Loss {:.4f} | TrainAcc {:.4f} |"
"Epoch {:05d} | Time(s) {:.4f} | Loss {:.4f} | TrainAcc {:.4f} |"
" ValAcc {:.4f} | ETputs(KTEPS) {:.2f}"
.
format
(
" ValAcc {:.4f} | ETputs(KTEPS) {:.2f}"
.
format
(
epoch
,
epoch
,
np
.
mean
(
dur
)
,
mean
,
loss
.
item
(),
loss
.
item
(),
train_acc
,
train_acc
,
val_acc
,
val_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