class*args, **kwargs)

Voxel pooling for 3D point clouds.

Spatial pooling for point clouds by combining points that fall into the same voxel bin.

The voxel grid used for pooling is always aligned to the origin (0,0,0) to simplify building voxel grid hierarchies. The order of the returned voxels is not defined as can be seen in the following example:

import as ml3d

positions = [

features = [[1.0,2.0],

voxel_pooling = ml3d.layers.VoxelPooling(position_fn='center', feature_fn='max')

ans = voxel_pooling(positions, features, 1.0)

# returns the voxel centers in
# ans.pooled_positions = [[0.5, 2.5, 1.5],
#                         [1.5, 1.5, 1.5],
#                         [0.5, 0.5, 0.5]]
# and the max pooled features for each voxel in
# ans.pooled_features = [[2.3, 1.9],
#                        [4.2, 3.4],
#                        [1.1, 2.3]]
  • position_fn

    Defines how the new point positions will be computed. The options are

    • ”average” computes the center of gravity for the points within one voxel.

    • ”nearest_neighbor” selects the point closest to the voxel center.

    • ”center” uses the voxel center for the position of the generated point.

  • feature_fn

    Defines how the pooled features will be computed. The options are

    • ”average” computes the average feature vector.

    • ”nearest_neighbor” selects the feature vector of the point closest to the voxel center.

    • ”max” uses the maximum feature among all points within the voxel.

__init__(position_fn='center', feature_fn='max', **kwargs)

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.


input_shape – Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

call(positions, features, voxel_size)

This function computes the pooled positions and features.

  • positions – The point positions with shape [N,3] with N as the number of points. This argument must be given as a positional argument!

  • features – The feature vector with shape [N,channels].

  • voxel_size – The voxel size.


2 Tensors in the following order


The output point positions with shape [M,3] and M <= N.


The output point features with shape [M,channnels] and M <= N.