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
829c073f
Unverified
Commit
829c073f
authored
Nov 28, 2023
by
LastWhisper
Committed by
GitHub
Nov 28, 2023
Browse files
[Benchmark] Fix bugs in the DGL link prediction example. (#6630)
parent
8394df7a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
examples/sampling/link_prediction.py
examples/sampling/link_prediction.py
+10
-3
No files found.
examples/sampling/link_prediction.py
View file @
829c073f
...
...
@@ -40,6 +40,7 @@ main
"""
import
argparse
import
time
import
dgl
import
dgl.nn
as
dglnn
...
...
@@ -348,6 +349,7 @@ def train(
use_uva
=
use_uva
,
)
opt
=
torch
.
optim
.
Adam
(
model
.
parameters
(),
lr
=
args
.
lr
)
start_epoch_time
=
time
.
time
()
for
epoch
in
range
(
args
.
epochs
):
model
.
train
()
total_loss
=
0
...
...
@@ -378,7 +380,12 @@ def train(
total_loss
+=
loss
.
item
()
if
(
it
+
1
)
==
args
.
early_stop
:
break
print
(
f
"Epoch
{
epoch
:
05
d
}
| Loss
{
total_loss
/
(
it
+
1
):.
4
f
}
"
)
end_epoch_time
=
time
.
time
()
print
(
f
"Epoch
{
epoch
:
05
d
}
| "
f
"Loss
{
total_loss
/
(
it
+
1
):.
4
f
}
| "
f
"Time
{
(
end_epoch_time
-
start_epoch_time
):.
4
f
}
s"
)
def
parse_args
():
...
...
@@ -450,8 +457,8 @@ def main(args):
# Convert the graph to its bidirectional form.
g
,
reverse_eids
=
to_bidirected_with_reverse_mapping
(
g
)
reverse_eids
=
reverse_eids
.
to
(
device
)
seed_edges
=
torch
.
arange
(
g
.
num_edges
()).
to
(
device
)
reverse_eids
=
reverse_eids
.
to
(
g
.
device
)
seed_edges
=
torch
.
arange
(
g
.
num_edges
()).
to
(
g
.
device
)
edge_split
=
dataset
.
get_edge_split
()
# Create GraphSAGE model.
...
...
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