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
pyg_autoscale
Commits
07932207
Commit
07932207
authored
Jun 08, 2021
by
rusty1s
Browse files
restructure
parent
ec590171
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
examples/train_gin.py
examples/train_gin.py
+8
-7
No files found.
examples/train_gin.py
View file @
07932207
...
...
@@ -105,6 +105,7 @@ class GIN(ScalableGNN):
@
torch
.
no_grad
()
def
forward_layer
(
self
,
layer
:
int
,
x
:
Tensor
,
adj_t
:
SparseTensor
,
state
):
# Perform layer-wise inference:
if
layer
==
0
:
x
=
self
.
lins
[
0
](
x
).
relu_
()
...
...
@@ -148,6 +149,13 @@ def train(model, loader, optimizer):
return
total_loss
/
total_examples
@
torch
.
no_grad
()
def
mini_test
(
model
,
loader
,
y
):
model
.
eval
()
out
=
model
(
loader
=
loader
)
return
int
((
out
.
argmax
(
dim
=-
1
)
==
y
).
sum
())
/
y
.
size
(
0
)
@
torch
.
no_grad
()
def
full_test
(
model
,
loader
):
model
.
eval
()
...
...
@@ -162,13 +170,6 @@ def full_test(model, loader):
return
total_correct
/
total_examples
@
torch
.
no_grad
()
def
mini_test
(
model
,
loader
,
y
):
model
.
eval
()
out
=
model
(
loader
=
loader
)
return
int
((
out
.
argmax
(
dim
=-
1
)
==
y
).
sum
())
/
y
.
size
(
0
)
mini_test
(
model
,
eval_loader
,
data
.
y
)
# Fill history.
for
epoch
in
range
(
1
,
151
):
...
...
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