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
812f5970
"git@developer.sourcefind.cn:change/sglang.git" did not exist on "7ba3de0e921c31e7dafa2b06228a180c2451c1cd"
Unverified
Commit
812f5970
authored
Nov 10, 2020
by
Mufei Li
Committed by
GitHub
Nov 10, 2020
Browse files
Update appnpconv.py (#2324)
parent
88a042d3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
python/dgl/nn/pytorch/conv/appnpconv.py
python/dgl/nn/pytorch/conv/appnpconv.py
+8
-5
No files found.
python/dgl/nn/pytorch/conv/appnpconv.py
View file @
812f5970
...
...
@@ -88,13 +88,16 @@ class APPNPConv(nn.Module):
should be the same as input shape.
"""
with
graph
.
local_scope
():
norm
=
th
.
pow
(
graph
.
in_degrees
().
float
().
clamp
(
min
=
1
),
-
0.5
)
shp
=
norm
.
shape
+
(
1
,)
*
(
feat
.
dim
()
-
1
)
norm
=
th
.
reshape
(
norm
,
shp
).
to
(
feat
.
device
)
src_norm
=
th
.
pow
(
graph
.
out_degrees
().
float
().
clamp
(
min
=
1
),
-
0.5
)
shp
=
src_norm
.
shape
+
(
1
,)
*
(
feat
.
dim
()
-
1
)
src_norm
=
th
.
reshape
(
src_norm
,
shp
).
to
(
feat
.
device
)
dst_norm
=
th
.
pow
(
graph
.
in_degrees
().
float
().
clamp
(
min
=
1
),
-
0.5
)
shp
=
dst_norm
.
shape
+
(
1
,)
*
(
feat
.
dim
()
-
1
)
dst_norm
=
th
.
reshape
(
dst_norm
,
shp
).
to
(
feat
.
device
)
feat_0
=
feat
for
_
in
range
(
self
.
_k
):
# normalization by src node
feat
=
feat
*
norm
feat
=
feat
*
src_
norm
graph
.
ndata
[
'h'
]
=
feat
graph
.
edata
[
'w'
]
=
self
.
edge_drop
(
th
.
ones
(
graph
.
number_of_edges
(),
1
).
to
(
feat
.
device
))
...
...
@@ -102,6 +105,6 @@ class APPNPConv(nn.Module):
fn
.
sum
(
'm'
,
'h'
))
feat
=
graph
.
ndata
.
pop
(
'h'
)
# normalization by dst node
feat
=
feat
*
norm
feat
=
feat
*
dst_
norm
feat
=
(
1
-
self
.
_alpha
)
*
feat
+
self
.
_alpha
*
feat_0
return
feat
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