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
964fd020
"torchvision/git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "f0a13fdcc00a1f76745d019b37346ecea375f500"
Unverified
Commit
964fd020
authored
Nov 09, 2023
by
LastWhisper
Committed by
GitHub
Nov 09, 2023
Browse files
[Example] Add early stop option for better regression test. (#6545)
parent
d79701db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
examples/sampling/link_prediction.py
examples/sampling/link_prediction.py
+8
-0
No files found.
examples/sampling/link_prediction.py
View file @
964fd020
...
@@ -370,6 +370,8 @@ def train(args, device, g, reverse_eids, seed_edges, model, use_uva):
...
@@ -370,6 +370,8 @@ def train(args, device, g, reverse_eids, seed_edges, model, use_uva):
loss
.
backward
()
loss
.
backward
()
opt
.
step
()
opt
.
step
()
total_loss
+=
loss
.
item
()
total_loss
+=
loss
.
item
()
if
(
it
+
1
)
==
args
.
early_stop
:
break
print
(
f
"Epoch
{
epoch
:
05
d
}
| Loss
{
total_loss
/
(
it
+
1
):.
4
f
}
"
)
print
(
f
"Epoch
{
epoch
:
05
d
}
| Loss
{
total_loss
/
(
it
+
1
):.
4
f
}
"
)
...
@@ -387,6 +389,12 @@ def parse_args():
...
@@ -387,6 +389,12 @@ def parse_args():
default
=
512
,
default
=
512
,
help
=
"Batch size. Default: 512"
,
help
=
"Batch size. Default: 512"
,
)
)
parser
.
add_argument
(
"--early-stop"
,
type
=
int
,
default
=
0
,
help
=
"0 means no early stop, otherwise stop at the input-th step"
,
)
parser
.
add_argument
(
parser
.
add_argument
(
"--mode"
,
"--mode"
,
default
=
"mixed"
,
default
=
"mixed"
,
...
...
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