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
efe0b061
Unverified
Commit
efe0b061
authored
Nov 05, 2021
by
Xin Yao
Committed by
GitHub
Nov 05, 2021
Browse files
fix test dataloader (#3482)
Co-authored-by:
Rhett Ying
<
85214957+Rhett-Ying@users.noreply.github.com
>
parent
c5ae54bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
tests/pytorch/test_dataloader.py
tests/pytorch/test_dataloader.py
+8
-8
No files found.
tests/pytorch/test_dataloader.py
View file @
efe0b061
...
...
@@ -217,8 +217,8 @@ def _check_device(data):
def
test_node_dataloader
():
sampler
=
dgl
.
dataloading
.
MultiLayerFullNeighborSampler
(
2
)
g1
=
dgl
.
graph
(([
0
,
0
,
0
,
1
,
1
],
[
1
,
2
,
3
,
3
,
4
]))
.
to
(
F
.
ctx
())
g1
.
ndata
[
'feat'
]
=
F
.
copy_to
(
F
.
randn
((
5
,
8
)),
F
.
c
tx
())
g1
=
dgl
.
graph
(([
0
,
0
,
0
,
1
,
1
],
[
1
,
2
,
3
,
3
,
4
]))
g1
.
ndata
[
'feat'
]
=
F
.
copy_to
(
F
.
randn
((
5
,
8
)),
F
.
c
pu
())
dataloader
=
dgl
.
dataloading
.
NodeDataLoader
(
g1
,
g1
.
nodes
(),
sampler
,
device
=
F
.
ctx
(),
batch_size
=
g1
.
num_nodes
())
...
...
@@ -232,9 +232,9 @@ def test_node_dataloader():
(
'user'
,
'followed-by'
,
'user'
):
([
1
,
2
,
3
,
0
,
2
,
3
,
0
],
[
0
,
0
,
0
,
1
,
1
,
1
,
2
]),
(
'user'
,
'play'
,
'game'
):
([
0
,
1
,
1
,
3
,
5
],
[
0
,
1
,
2
,
0
,
2
]),
(
'game'
,
'played-by'
,
'user'
):
([
0
,
1
,
2
,
0
,
2
],
[
0
,
1
,
1
,
3
,
5
])
})
.
to
(
F
.
ctx
())
})
for
ntype
in
g2
.
ntypes
:
g2
.
nodes
[
ntype
].
data
[
'feat'
]
=
F
.
copy_to
(
F
.
randn
((
g2
.
num_nodes
(
ntype
),
8
)),
F
.
c
tx
())
g2
.
nodes
[
ntype
].
data
[
'feat'
]
=
F
.
copy_to
(
F
.
randn
((
g2
.
num_nodes
(
ntype
),
8
)),
F
.
c
pu
())
batch_size
=
max
(
g2
.
num_nodes
(
nty
)
for
nty
in
g2
.
ntypes
)
dataloader
=
dgl
.
dataloading
.
NodeDataLoader
(
...
...
@@ -250,8 +250,8 @@ def test_edge_dataloader():
sampler
=
dgl
.
dataloading
.
MultiLayerFullNeighborSampler
(
2
)
neg_sampler
=
dgl
.
dataloading
.
negative_sampler
.
Uniform
(
2
)
g1
=
dgl
.
graph
(([
0
,
0
,
0
,
1
,
1
],
[
1
,
2
,
3
,
3
,
4
]))
.
to
(
F
.
ctx
())
g1
.
ndata
[
'feat'
]
=
F
.
copy_to
(
F
.
randn
((
5
,
8
)),
F
.
c
tx
())
g1
=
dgl
.
graph
(([
0
,
0
,
0
,
1
,
1
],
[
1
,
2
,
3
,
3
,
4
]))
g1
.
ndata
[
'feat'
]
=
F
.
copy_to
(
F
.
randn
((
5
,
8
)),
F
.
c
pu
())
# no negative sampler
dataloader
=
dgl
.
dataloading
.
EdgeDataLoader
(
...
...
@@ -276,9 +276,9 @@ def test_edge_dataloader():
(
'user'
,
'followed-by'
,
'user'
):
([
1
,
2
,
3
,
0
,
2
,
3
,
0
],
[
0
,
0
,
0
,
1
,
1
,
1
,
2
]),
(
'user'
,
'play'
,
'game'
):
([
0
,
1
,
1
,
3
,
5
],
[
0
,
1
,
2
,
0
,
2
]),
(
'game'
,
'played-by'
,
'user'
):
([
0
,
1
,
2
,
0
,
2
],
[
0
,
1
,
1
,
3
,
5
])
})
.
to
(
F
.
ctx
())
})
for
ntype
in
g2
.
ntypes
:
g2
.
nodes
[
ntype
].
data
[
'feat'
]
=
F
.
copy_to
(
F
.
randn
((
g2
.
num_nodes
(
ntype
),
8
)),
F
.
c
tx
())
g2
.
nodes
[
ntype
].
data
[
'feat'
]
=
F
.
copy_to
(
F
.
randn
((
g2
.
num_nodes
(
ntype
),
8
)),
F
.
c
pu
())
batch_size
=
max
(
g2
.
num_edges
(
ety
)
for
ety
in
g2
.
canonical_etypes
)
# no negative sampler
...
...
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