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
06d471ed
Commit
06d471ed
authored
Apr 07, 2018
by
rusty1s
Browse files
added docstring
parent
1b0fcb63
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
torch_cluster/graclus.py
torch_cluster/graclus.py
+18
-0
torch_cluster/grid.py
torch_cluster/grid.py
+19
-0
No files found.
torch_cluster/graclus.py
View file @
06d471ed
...
@@ -3,6 +3,24 @@ from .utils.ffi import graclus
...
@@ -3,6 +3,24 @@ from .utils.ffi import graclus
def
graclus_cluster
(
row
,
col
,
weight
=
None
,
num_nodes
=
None
):
def
graclus_cluster
(
row
,
col
,
weight
=
None
,
num_nodes
=
None
):
"""Greedy clustering algorithm of picking an unmarked vertex and matching
it with one its unmarked neighbors (that maximizes its optionally edge
weight).
Args:
row (LongTensor): Source nodes.
col (LongTensor): Target nodes.
weight (Tensor, optional): Edge weights. (default: :obj:`None`)
num_nodes (int, optional): The number of nodes. (default: :obj:`None`)
Examples::
>>> row = torch.LongTensor([0, 1, 1, 2])
>>> col = torch.LongTensor([1, 0, 2, 1])
>>> weight = torch.Tensor([1, 1, 1, 1])
>>> cluster = graclus_cluster(row, col, weight)
"""
num_nodes
=
row
.
max
()
+
1
if
num_nodes
is
None
else
num_nodes
num_nodes
=
row
.
max
()
+
1
if
num_nodes
is
None
else
num_nodes
if
row
.
is_cuda
:
# pragma: no cover
if
row
.
is_cuda
:
# pragma: no cover
...
...
torch_cluster/grid.py
View file @
06d471ed
...
@@ -2,6 +2,25 @@ from .utils.ffi import grid
...
@@ -2,6 +2,25 @@ from .utils.ffi import grid
def
grid_cluster
(
pos
,
size
,
start
=
None
,
end
=
None
):
def
grid_cluster
(
pos
,
size
,
start
=
None
,
end
=
None
):
"""Voxel grid clustering algorithm, which overlays a regular grid of
user-defined size over the point cloud and clusters all points within a
voxel.
Args:
pos (Tensor): D-dimensional position of points.
size (Tensor): Size of a voxel in each dimension.
start (Tensor or int, optional): Start position of the grid (in each
dimension). (default: :obj:`None`)
end (Tensor or int, optional): End position of the grid (in each
dimension). (default: :obj:`None`)
Examples::
>>> pos = torch.Tensor([[0, 0], [11, 9], [2, 8], [2, 2], [8, 3]])
>>> size = torch.Tensor([5, 5])
>>> cluster = grid_cluster(pos, size)
"""
pos
=
pos
.
unsqueeze
(
-
1
)
if
pos
.
dim
()
==
1
else
pos
pos
=
pos
.
unsqueeze
(
-
1
)
if
pos
.
dim
()
==
1
else
pos
assert
pos
.
size
(
1
)
==
size
.
size
(
0
),
(
assert
pos
.
size
(
1
)
==
size
.
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