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
torch-spline-conv
Commits
08a517fe
Commit
08a517fe
authored
Apr 27, 2018
by
rusty1s
Browse files
better degree impl
parent
af754235
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
5 deletions
+3
-5
torch_spline_conv/conv.py
torch_spline_conv/conv.py
+1
-1
torch_spline_conv/utils/degree.py
torch_spline_conv/utils/degree.py
+2
-4
No files found.
torch_spline_conv/conv.py
View file @
08a517fe
...
@@ -63,7 +63,7 @@ class SplineConv(object):
...
@@ -63,7 +63,7 @@ class SplineConv(object):
output
=
src
.
new_zeros
((
n
,
m_out
)).
scatter_add_
(
0
,
row_expand
,
output
)
output
=
src
.
new_zeros
((
n
,
m_out
)).
scatter_add_
(
0
,
row_expand
,
output
)
# Normalize output by node degree.
# Normalize output by node degree.
deg
=
node_degree
(
row
,
n
,
out
=
src
.
new_empty
(())
)
deg
=
node_degree
(
row
,
n
,
out
put
.
dtype
,
output
.
device
)
output
/=
deg
.
unsqueeze
(
-
1
).
clamp
(
min
=
1
)
output
/=
deg
.
unsqueeze
(
-
1
).
clamp
(
min
=
1
)
# Weight root node separately (if wished).
# Weight root node separately (if wished).
...
...
torch_spline_conv/utils/degree.py
View file @
08a517fe
import
torch
import
torch
def
degree
(
index
,
num_nodes
=
None
,
out
=
None
):
def
degree
(
index
,
num_nodes
=
None
,
dtype
=
None
,
device
=
None
):
num_nodes
=
index
.
max
()
+
1
if
num_nodes
is
None
else
num_nodes
num_nodes
=
index
.
max
()
+
1
if
num_nodes
is
None
else
num_nodes
out
=
index
.
new_empty
((),
dtype
=
torch
.
float
)
if
out
is
None
else
out
out
=
torch
.
zeros
((
num_nodes
),
dtype
=
dtype
,
device
=
device
)
out
.
resize_
(
num_nodes
).
fill_
(
0
)
return
out
.
scatter_add_
(
0
,
index
,
out
.
new_ones
((
index
.
size
(
0
))))
return
out
.
scatter_add_
(
0
,
index
,
out
.
new_ones
((
index
.
size
(
0
))))
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