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
bbc25706
Commit
bbc25706
authored
Jan 13, 2018
by
rusty1s
Browse files
added python impl
parent
af7786d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
6 deletions
+2
-6
torch_cluster/functions/grid.py
torch_cluster/functions/grid.py
+2
-6
No files found.
torch_cluster/functions/grid.py
View file @
bbc25706
...
...
@@ -5,17 +5,12 @@ from .utils import get_func
def
grid_cluster
(
position
,
size
,
batch
=
None
):
# TODO: Check types and sizes
print
(
batch
.
type
())
print
(
position
.
type
())
if
batch
is
not
None
:
batch
=
batch
.
type_as
(
position
)
position
=
torch
.
cat
([
position
,
batch
],
dim
=
position
.
dim
()
-
1
)
size
=
torch
.
cat
([
size
,
size
.
new
(
1
).
fill_
(
1
)],
dim
=
0
)
print
(
position
)
# TODO: BATCH
# print(position[0])
# print(position[1])
dim
=
position
.
dim
()
# Allow one-dimensional positions.
...
...
@@ -32,6 +27,7 @@ def grid_cluster(position, size, batch=None):
while
max
.
dim
()
>
1
:
max
=
max
.
max
(
dim
=
0
)[
0
]
c_max
=
torch
.
ceil
(
max
/
size
.
type_as
(
max
)).
long
()
c_max
=
torch
.
clamp
(
c_max
,
min
=
1
)
C
=
c_max
.
prod
()
# Generate cluster tensor.
...
...
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