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
a6bd96aa
Unverified
Commit
a6bd96aa
authored
Jun 30, 2022
by
Chang Liu
Committed by
GitHub
Jun 30, 2022
Browse files
Fix example crashes due to DGL API update (#4194)
Co-authored-by:
Xin Yao
<
xiny@nvidia.com
>
parent
f7dae453
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
16 additions
and
18 deletions
+16
-18
examples/pytorch/appnp/train.py
examples/pytorch/appnp/train.py
+1
-1
examples/pytorch/dgi/train.py
examples/pytorch/dgi/train.py
+2
-4
examples/pytorch/gat/train.py
examples/pytorch/gat/train.py
+1
-1
examples/pytorch/gatv2/train.py
examples/pytorch/gatv2/train.py
+3
-3
examples/pytorch/gcn/gcn_mp.py
examples/pytorch/gcn/gcn_mp.py
+1
-1
examples/pytorch/gcn/train.py
examples/pytorch/gcn/train.py
+1
-1
examples/pytorch/graphsage/train_full.py
examples/pytorch/graphsage/train_full.py
+1
-1
examples/pytorch/hardgat/train.py
examples/pytorch/hardgat/train.py
+1
-1
examples/pytorch/model_zoo/citation_network/run.py
examples/pytorch/model_zoo/citation_network/run.py
+1
-1
examples/pytorch/monet/citation.py
examples/pytorch/monet/citation.py
+1
-1
examples/pytorch/sgc/sgc.py
examples/pytorch/sgc/sgc.py
+1
-1
examples/pytorch/sgc/sgc_reddit.py
examples/pytorch/sgc/sgc_reddit.py
+2
-2
No files found.
examples/pytorch/appnp/train.py
View file @
a6bd96aa
...
...
@@ -45,7 +45,7 @@ def main(args):
test_mask
=
g
.
ndata
[
'test_mask'
]
in_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_labels
n_edges
=
data
.
graph
.
number_of_edges
()
n_edges
=
g
.
number_of_edges
()
print
(
"""----Data statistics------'
#Edges %d
#Classes %d
...
...
examples/pytorch/dgi/train.py
View file @
a6bd96aa
...
...
@@ -21,6 +21,7 @@ def evaluate(model, features, labels, mask):
def
main
(
args
):
# load and preprocess dataset
data
=
load_data
(
args
)
g
=
data
[
0
]
features
=
torch
.
FloatTensor
(
data
.
features
)
labels
=
torch
.
LongTensor
(
data
.
labels
)
if
hasattr
(
torch
,
'BoolTensor'
):
...
...
@@ -33,7 +34,7 @@ def main(args):
test_mask
=
torch
.
ByteTensor
(
data
.
test_mask
)
in_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_labels
n_edges
=
data
.
graph
.
number_of_edges
()
n_edges
=
g
.
number_of_edges
()
if
args
.
gpu
<
0
:
cuda
=
False
...
...
@@ -46,13 +47,10 @@ def main(args):
val_mask
=
val_mask
.
cuda
()
test_mask
=
test_mask
.
cuda
()
# graph preprocess
g
=
data
.
graph
# add self loop
if
args
.
self_loop
:
g
.
remove_edges_from
(
nx
.
selfloop_edges
(
g
))
g
.
add_edges_from
(
zip
(
g
.
nodes
(),
g
.
nodes
()))
g
=
DGLGraph
(
g
)
n_edges
=
g
.
number_of_edges
()
if
args
.
gpu
>=
0
:
...
...
examples/pytorch/gat/train.py
View file @
a6bd96aa
...
...
@@ -62,7 +62,7 @@ def main(args):
test_mask
=
g
.
ndata
[
'test_mask'
]
num_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_labels
n_edges
=
data
.
graph
.
number_of_edges
()
n_edges
=
g
.
number_of_edges
()
print
(
"""----Data statistics------'
#Edges %d
#Classes %d
...
...
examples/pytorch/gatv2/train.py
View file @
a6bd96aa
...
...
@@ -48,7 +48,7 @@ def accuracy(logits, labels):
return
correct
.
item
()
*
1.0
/
len
(
labels
)
def
evaluate
(
model
,
g
,
features
,
labels
,
mask
):
def
evaluate
(
g
,
model
,
features
,
labels
,
mask
):
model
.
eval
()
with
torch
.
no_grad
():
logits
=
model
(
g
,
features
)
...
...
@@ -82,7 +82,7 @@ def main(args):
test_mask
=
g
.
ndata
[
'test_mask'
]
num_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_labels
n_edges
=
data
.
graph
.
number_of_edges
()
n_edges
=
g
.
number_of_edges
()
print
(
"""----Data statistics------'
#Edges %d
#Classes %d
...
...
@@ -156,7 +156,7 @@ def main(args):
print
()
if
args
.
early_stop
:
model
.
load_state_dict
(
torch
.
load
(
'es_checkpoint.pt'
))
acc
=
evaluate
(
model
,
features
,
labels
,
test_mask
)
acc
=
evaluate
(
g
,
model
,
features
,
labels
,
test_mask
)
print
(
"Test Accuracy {:.4f}"
.
format
(
acc
))
...
...
examples/pytorch/gcn/gcn_mp.py
View file @
a6bd96aa
...
...
@@ -140,7 +140,7 @@ def main(args):
test_mask
=
g
.
ndata
[
'test_mask'
]
in_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_labels
n_edges
=
data
.
graph
.
number_of_edges
()
n_edges
=
g
.
number_of_edges
()
print
(
"""----Data statistics------'
#Edges %d
#Classes %d
...
...
examples/pytorch/gcn/train.py
View file @
a6bd96aa
...
...
@@ -47,7 +47,7 @@ def main(args):
test_mask
=
g
.
ndata
[
'test_mask'
]
in_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_labels
n_edges
=
data
.
graph
.
number_of_edges
()
n_edges
=
g
.
number_of_edges
()
print
(
"""----Data statistics------'
#Edges %d
#Classes %d
...
...
examples/pytorch/graphsage/train_full.py
View file @
a6bd96aa
...
...
@@ -70,7 +70,7 @@ def main(args):
test_mask
=
g
.
ndata
[
'test_mask'
]
in_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_classes
n_edges
=
data
.
graph
.
number_of_edges
()
n_edges
=
g
.
number_of_edges
()
print
(
"""----Data statistics------'
#Edges %d
#Classes %d
...
...
examples/pytorch/hardgat/train.py
View file @
a6bd96aa
...
...
@@ -60,7 +60,7 @@ def main(args):
test_mask
=
g
.
ndata
[
'test_mask'
]
num_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_labels
n_edges
=
data
.
graph
.
number_of_edges
()
n_edges
=
g
.
number_of_edges
()
print
(
"""----Data statistics------'
#Edges %d
#Classes %d
...
...
examples/pytorch/model_zoo/citation_network/run.py
View file @
a6bd96aa
...
...
@@ -57,7 +57,7 @@ def main(args):
test_mask
=
g
.
ndata
[
'test_mask'
]
in_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_labels
n_edges
=
data
.
graph
.
number_of_edges
()
n_edges
=
g
.
number_of_edges
()
print
(
"""----Data statistics------'
#Edges %d
#Classes %d
...
...
examples/pytorch/monet/citation.py
View file @
a6bd96aa
...
...
@@ -78,7 +78,7 @@ def main(args):
test_mask
=
g
.
ndata
[
'test_mask'
]
in_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_labels
n_edges
=
data
.
graph
.
number_of_edges
()
n_edges
=
g
.
number_of_edges
()
print
(
"""----Data statistics------'
#Edges %d
#Classes %d
...
...
examples/pytorch/sgc/sgc.py
View file @
a6bd96aa
...
...
@@ -51,7 +51,7 @@ def main(args):
test_mask
=
g
.
ndata
[
'test_mask'
]
in_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_labels
n_edges
=
data
.
graph
.
number_of_edges
()
n_edges
=
g
.
number_of_edges
()
print
(
"""----Data statistics------'
#Edges %d
#Classes %d
...
...
examples/pytorch/sgc/sgc_reddit.py
View file @
a6bd96aa
...
...
@@ -31,7 +31,7 @@ def main(args):
# load and preprocess dataset
args
.
dataset
=
"reddit-self-loop"
data
=
load_data
(
args
)
g
=
data
.
graph
g
=
data
[
0
]
if
args
.
gpu
<
0
:
cuda
=
False
else
:
...
...
@@ -45,7 +45,7 @@ def main(args):
test_mask
=
g
.
ndata
[
'test_mask'
]
in_feats
=
features
.
shape
[
1
]
n_classes
=
data
.
num_labels
n_edges
=
data
.
graph
.
number_of_edges
()
n_edges
=
g
.
number_of_edges
()
print
(
"""----Data statistics------'
#Edges %d
#Classes %d
...
...
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