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
c45f6eb5
Unverified
Commit
c45f6eb5
authored
Jan 26, 2021
by
Jinjing Zhou
Committed by
GitHub
Jan 26, 2021
Browse files
[Bugfix] Fix duplicate edges in Coauthor Dataset #2553 (#2569)
* fix * address comment
parent
6c23fba8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
python/dgl/data/gnn_benckmark.py
python/dgl/data/gnn_benckmark.py
+6
-6
No files found.
python/dgl/data/gnn_benckmark.py
View file @
c45f6eb5
...
...
@@ -7,6 +7,7 @@ from .dgl_dataset import DGLBuiltinDataset
from
.utils
import
save_graphs
,
load_graphs
,
_get_dgl_url
,
deprecate_property
,
deprecate_class
from
..convert
import
graph
as
dgl_graph
from
..
import
backend
as
F
from
..
import
transform
__all__
=
[
"AmazonCoBuyComputerDataset"
,
"AmazonCoBuyPhotoDataset"
,
"CoauthorPhysicsDataset"
,
"CoauthorCSDataset"
,
"CoraFullDataset"
,
"AmazonCoBuy"
,
"Coauthor"
,
"CoraFull"
]
...
...
@@ -42,17 +43,17 @@ class GNNBenchmarkDataset(DGLBuiltinDataset):
self
.
_print_info
()
def
has_cache
(
self
):
graph_path
=
os
.
path
.
join
(
self
.
save_path
,
'dgl_graph.bin'
)
graph_path
=
os
.
path
.
join
(
self
.
save_path
,
'dgl_graph
_v1
.bin'
)
if
os
.
path
.
exists
(
graph_path
):
return
True
return
False
def
save
(
self
):
graph_path
=
os
.
path
.
join
(
self
.
save_path
,
'dgl_graph.bin'
)
graph_path
=
os
.
path
.
join
(
self
.
save_path
,
'dgl_graph
_v1
.bin'
)
save_graphs
(
graph_path
,
self
.
_graph
)
def
load
(
self
):
graph_path
=
os
.
path
.
join
(
self
.
save_path
,
'dgl_graph.bin'
)
graph_path
=
os
.
path
.
join
(
self
.
save_path
,
'dgl_graph
_v1
.bin'
)
graphs
,
_
=
load_graphs
(
graph_path
)
self
.
_graph
=
graphs
[
0
]
self
.
_data
=
[
graphs
[
0
]]
...
...
@@ -91,9 +92,8 @@ class GNNBenchmarkDataset(DGLBuiltinDataset):
labels
=
loader
[
'labels'
]
else
:
labels
=
None
row
=
np
.
hstack
([
adj_matrix
.
row
,
adj_matrix
.
col
])
col
=
np
.
hstack
([
adj_matrix
.
col
,
adj_matrix
.
row
])
g
=
dgl_graph
((
row
,
col
))
g
=
dgl_graph
((
adj_matrix
.
row
,
adj_matrix
.
col
))
g
=
transform
.
to_bidirected
(
g
)
g
.
ndata
[
'feat'
]
=
F
.
tensor
(
attr_matrix
,
F
.
data_type_dict
[
'float32'
])
g
.
ndata
[
'label'
]
=
F
.
tensor
(
labels
,
F
.
data_type_dict
[
'int64'
])
return
g
...
...
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