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
9fe5092c
Unverified
Commit
9fe5092c
authored
Feb 19, 2023
by
Hongzhi (Steve), Chen
Committed by
GitHub
Feb 19, 2023
Browse files
lintrunner (#5326)
Co-authored-by:
Ubuntu
<
ubuntu@ip-172-31-28-63.ap-northeast-1.compute.internal
>
parent
9836f78e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
122 additions
and
125 deletions
+122
-125
examples/pytorch/capsule/DGLRoutingLayer.py
examples/pytorch/capsule/DGLRoutingLayer.py
+82
-84
examples/pytorch/capsule/simple_routing.py
examples/pytorch/capsule/simple_routing.py
+40
-41
No files found.
examples/pytorch/capsule/DGLRoutingLayer.py
View file @
9fe5092c
...
@@ -46,7 +46,6 @@ class DGLRoutingLayer(nn.Module):
...
@@ -46,7 +46,6 @@ class DGLRoutingLayer(nn.Module):
self
.
g
.
nodes
[
self
.
out_indx
].
data
[
"v"
]
=
squash
(
self
.
g
.
nodes
[
self
.
out_indx
].
data
[
"v"
]
=
squash
(
self
.
g
.
nodes
[
self
.
out_indx
].
data
[
"s"
],
dim
=
1
self
.
g
.
nodes
[
self
.
out_indx
].
data
[
"s"
],
dim
=
1
)
)
# step 4 (line 7)
# step 4 (line 7)
v
=
th
.
cat
(
v
=
th
.
cat
(
[
self
.
g
.
nodes
[
self
.
out_indx
].
data
[
"v"
]]
*
self
.
in_nodes
,
dim
=
0
[
self
.
g
.
nodes
[
self
.
out_indx
].
data
[
"v"
]]
*
self
.
in_nodes
,
dim
=
0
...
@@ -78,7 +77,6 @@ def init_graph(in_nodes, out_nodes, f_size, device="cpu"):
...
@@ -78,7 +77,6 @@ def init_graph(in_nodes, out_nodes, f_size, device="cpu"):
# add edges use edge broadcasting
# add edges use edge broadcasting
for
u
in
in_indx
:
for
u
in
in_indx
:
g
.
add_edges
(
u
,
out_indx
)
g
.
add_edges
(
u
,
out_indx
)
g
=
g
.
to
(
device
)
g
=
g
.
to
(
device
)
g
.
edata
[
"b"
]
=
th
.
zeros
(
in_nodes
*
out_nodes
,
1
).
to
(
device
)
g
.
edata
[
"b"
]
=
th
.
zeros
(
in_nodes
*
out_nodes
,
1
).
to
(
device
)
return
g
return
g
examples/pytorch/capsule/simple_routing.py
View file @
9fe5092c
...
@@ -23,7 +23,6 @@ g.graph_data["out_indx"] = out_indx
...
@@ -23,7 +23,6 @@ g.graph_data["out_indx"] = out_indx
# add edges use edge broadcasting
# add edges use edge broadcasting
for
u
in
out_indx
:
for
u
in
out_indx
:
g
.
add_edges
(
in_indx
,
u
)
g
.
add_edges
(
in_indx
,
u
)
# init states
# init states
f_size
=
4
f_size
=
4
g
.
ndata
[
"v"
]
=
th
.
zeros
(
all_nodes
,
f_size
)
g
.
ndata
[
"v"
]
=
th
.
zeros
(
all_nodes
,
f_size
)
...
...
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