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-cluster
Commits
abac33d3
Commit
abac33d3
authored
Mar 25, 2018
by
rusty1s
Browse files
removed rid args
parent
63c0dad6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
12 deletions
+6
-12
torch_cluster/functions/permute.py
torch_cluster/functions/permute.py
+4
-6
torch_cluster/functions/random.py
torch_cluster/functions/random.py
+2
-6
No files found.
torch_cluster/functions/permute.py
View file @
abac33d3
import
torch
def
permute
(
edge_index
,
num_nodes
,
rid
=
None
,
perm_edges
=
True
):
def
random_
permute
(
edge_index
,
num_nodes
):
row
,
col
=
edge_index
if
perm_edges
:
edge_rid
=
torch
.
randperm
(
row
.
size
(
0
))
row
,
col
=
row
[
edge_rid
],
col
[
edge_rid
]
rid
=
torch
.
randperm
(
row
.
size
(
0
))
row
,
col
=
row
[
rid
],
col
[
rid
]
rid
=
torch
.
randperm
(
num_nodes
)
if
rid
is
None
else
rid
_
,
perm
=
rid
[
row
].
sort
()
_
,
perm
=
rid
[
torch
.
randperm
(
num_nodes
)].
sort
()
row
,
col
=
row
[
perm
],
col
[
perm
]
return
torch
.
stack
([
row
,
col
],
dim
=
0
)
torch_cluster/functions/random.py
View file @
abac33d3
...
...
@@ -3,14 +3,10 @@ from .degree import node_degree
from
.permute
import
permute
def
random_cluster
(
edge_index
,
batch
=
None
,
rid
=
None
,
perm_edges
=
True
,
num_nodes
=
None
):
def
random_cluster
(
edge_index
,
batch
=
None
,
num_nodes
=
None
):
num_nodes
=
edge_index
.
max
()
+
1
if
num_nodes
is
None
else
num_nodes
row
,
col
=
permute
(
edge_index
,
num_nodes
,
rid
,
perm_edges
)
row
,
col
=
permute
(
edge_index
,
num_nodes
)
degree
=
node_degree
(
row
,
num_nodes
,
out
=
row
.
new
())
cluster
=
edge_index
.
new
(
num_nodes
).
fill_
(
-
1
)
...
...
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