voxel_grid
¶
voxel_grid(
pos: array,
size: Union[float, Sequence[float], array],
batch: Optional[array] = None,
start: Optional[Union[float, Sequence[float], array]] = None,
end: Optional[Union[float, Sequence[float], array]] = None,
) -> array
Voxel grid pooling from the "Dynamic Edge-Conditioned Filters in Convolutional Networks on Graphs" paper: overlays a regular grid of user-defined size over a point cloud and clusters all the points within the same voxel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos
|
array
|
Node positions, of shape |
required |
size
|
Union[float, Sequence[float], array]
|
Size of a voxel (in each dimension, or the same for all). |
required |
batch
|
Optional[array]
|
Graph of each node, of shape |
None
|
start
|
Optional[Union[float, Sequence[float], array]]
|
Start coordinates of the grid (in each dimension, or the same
for all). Default: |
None
|
end
|
Optional[Union[float, Sequence[float], array]]
|
End coordinates of the grid. Default: |
None
|
Returns:
| Type | Description |
|---|---|
array
|
The voxel (cluster) id of each node, of shape |
array
|
are not consecutive, see |
Example:
import mlx.core as mx
from mlx_graphs.utils import voxel_grid
pos = mx.array([[0.0, 0.0], [0.4, 0.2], [1.5, 0.1], [0.2, 1.7]])
>>> voxel_grid(pos, size=1.0)
array([0, 0, 1, 2], dtype=int64)
Source code in mlx_graphs/utils/clustering.py
from mlx_graphs.nn import voxel_grid · mlx_graphs/utils/clustering.py