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
9432cd63
Unverified
Commit
9432cd63
authored
Mar 10, 2020
by
Da Zheng
Committed by
GitHub
Mar 11, 2020
Browse files
fix sampler. (#1350)
parent
988c8b20
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
apps/kg/dataloader/sampler.py
apps/kg/dataloader/sampler.py
+10
-5
No files found.
apps/kg/dataloader/sampler.py
View file @
9432cd63
...
...
@@ -434,14 +434,19 @@ def create_neg_subgraph(pos_g, neg_g, chunk_size, neg_sample_size, is_chunked,
# We use all nodes to create negative edges. Regardless of the sampling algorithm,
# we can always view the subgraph with one chunk.
if
(
neg_head
and
len
(
neg_g
.
head_nid
)
==
num_nodes
)
\
or
(
not
neg_head
and
len
(
neg_g
.
tail_nid
)
==
num_nodes
)
\
or
pos_g
.
number_of_edges
()
<
chunk_size
:
or
(
not
neg_head
and
len
(
neg_g
.
tail_nid
)
==
num_nodes
):
num_chunks
=
1
chunk_size
=
pos_g
.
number_of_edges
()
elif
is_chunked
:
# This is probably the last batch. Let's ignore it.
if
pos_g
.
number_of_edges
()
%
chunk_size
>
0
:
# This is probably for evaluation.
if
pos_g
.
number_of_edges
()
<
chunk_size
\
and
neg_g
.
number_of_edges
()
%
neg_sample_size
==
0
:
num_chunks
=
1
chunk_size
=
pos_g
.
number_of_edges
()
# This is probably the last batch in the training. Let's ignore it.
elif
pos_g
.
number_of_edges
()
%
chunk_size
>
0
:
return
None
else
:
num_chunks
=
int
(
pos_g
.
number_of_edges
()
/
chunk_size
)
assert
num_chunks
*
chunk_size
==
pos_g
.
number_of_edges
()
else
:
...
...
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