pointnet2_blocks
PointNet++ grouping convolution, set abstraction and feature propagation blocks.
Classes:
-
PointNet2ConvβPointNet++ grouping convolution on top of PyG's
MessagePassing. -
PointNet2SetAbstractionβSet-abstraction block (PointNet++ SSG / MSG) built from one
PointNet2Convper grouping scale. -
PointNet2GlobalSetAbstractionβGlobal set-abstraction block: a shared MLP followed by a pool over each batch element.
-
PointNet2FeaturePropagationβK-NN interpolation + skip concatenation + MLP, as in
PointNet2Conv [source] ΒΆ
PointNet2Conv(
local_nn: Module,
add_self_loops: bool = True,
use_pos: bool = True,
pos_first: bool = False,
pos_scale: Optional[float] = None,
**kwargs: Unpack[MessagePassingParams],
)
Bases: MessagePassing
PointNet++ grouping convolution on top of PyG's MessagePassing.
Each message combines the neighbor features \(x_j\) with the relative position \(p_j - p_i\) and applies local_nn; the messages of each centroid are then aggregated (aggr, max by default).
Parameters:
-
local_nn(Module) βNetwork applied to each message of shape \((E, C + D)\), or \((E, C)\) when
use_posis false. -
add_self_loops(bool, default:True) βWhether to add self-loops to the edge index.
-
use_pos(bool, default:True) βConcatenate the relative position \(p_j - p_i\) to the neighbor features.
-
pos_first(bool, default:False) βConcatenate the relative position before the features (
cat([p_j - p_i, x_j])) instead of after. -
pos_scale(Optional[float], default:None) βDivide the relative position by this value, e.g. the ball-query radius to normalize it.
-
**kwargs(Unpack[MessagePassingParams], default:{}) βAdditional
MessagePassingarguments (aggrdefaults to"max").
PointNet2SetAbstraction [source] ΒΆ
PointNet2SetAbstraction(
in_channels: int,
channels: Sequence[Union[int, Sequence[int]]],
*,
ratio: Optional[float] = None,
num_points: Optional[int] = None,
radii: Union[float, Sequence[float]],
num_neighbors: Union[int, Sequence[int]],
spatial_dim: int = 3,
dropout: float = 0.0,
act: Union[str, Callable, None] = "relu",
act_kwargs: Optional[Dict[str, Any]] = None,
act_first: bool = False,
norm: Union[str, Callable, None] = "batch_norm",
norm_kwargs: Optional[Dict[str, Any]] = None,
bias: bool = False,
use_pos: bool = True,
normalize_pos: bool = True,
pos_first: bool = False,
aggr: AggrType = "max",
sort_neighbors: bool = False,
)
Bases: Module
Set-abstraction block (PointNet++ SSG / MSG) built from one PointNet2Conv per grouping scale.
Farthest point sampling selects the centroids, a ball query gathers the neighbors of each centroid per scale, and the per-scale outputs are concatenated (Multi-Scale Grouping when channels is a nested sequence).
Parameters:
-
in_channels(int) βNumber of input feature channels.
-
channels(Sequence[Union[int, Sequence[int]]]) βPer-scale MLP channel sizes; a nested sequence enables Multi-Scale Grouping.
-
ratio(Optional[float], default:None) βFractional farthest-point-sampling rate. Mutually exclusive with
num_points. -
num_points(Optional[int], default:None) βAbsolute number of centroids to sample (e.g. VoteNet's fixed \(2048, 1024, \ldots\)). Exactly one of
ratio/num_pointsmust be given. A sample with fewer thannum_pointspoints yields repeated centroids (FPS samples with replacement to keep shapes stable). -
radii(Union[float, Sequence[float]]) βBall-query radius per scale.
-
num_neighbors(Union[int, Sequence[int]]) βMaximum number of neighbors per scale.
-
spatial_dim(int, default:3) βDimension of point coordinates.
-
dropout(float, default:0.0) βDropout rate inside the per-scale MLPs.
-
bias(bool, default:False) βWhether the MLP linear layers use a bias.
-
use_pos(bool, default:True) βConcatenate the relative position to the grouped features.
-
normalize_pos(bool, default:True) βDivide the relative position by the ball-query radius.
-
pos_first(bool, default:False) βConcatenate the relative position before the grouped features (
cat([rel_pos, x])) instead of after. VoteNet and the reference PointNet++ kernels use this order; keeping it a flag lets weights convert as a pure rename without a column swap. -
aggr(AggrType, default:'max') βAggregation of the messages of each centroid.
-
sort_neighbors(bool, default:False) βKeep the smallest source indices when a ball holds more than
num_neighborspoints, as the referencequery_ball_pointdoes.
PointNet2GlobalSetAbstraction [source] ΒΆ
PointNet2GlobalSetAbstraction(
in_channels: int,
channels: Sequence[int],
spatial_dim: int = 3,
dropout: float = 0.0,
act: Union[str, Callable, None] = "relu",
act_kwargs: Optional[Dict[str, Any]] = None,
act_first: bool = False,
norm: Union[str, Callable, None] = "batch_norm",
norm_kwargs: Optional[Dict[str, Any]] = None,
bias: bool = False,
use_pos: bool = False,
pos_first: bool = False,
aggr: PoolLike = "max",
)
Bases: Module
Global set-abstraction block: a shared MLP followed by a pool over each batch element.
Parameters:
-
in_channels(int) βNumber of input feature channels.
-
channels(Sequence[int]) βPer-layer channel sizes of the MLP.
-
spatial_dim(int, default:3) βDimension of point coordinates.
-
dropout(float, default:0.0) βDropout rate inside the MLP.
-
bias(bool, default:False) βWhether the MLP linear layers use a bias.
-
use_pos(bool, default:False) βConcatenate the absolute point positions to
xbefore the MLP. UnlikePointNet2SetAbstractionthere is no sampled centroid to offset against, so the coordinates enter unnormalized (the reference PointNet++GroupAll). -
pos_first(bool, default:False) βConcatenate the positions before the features (
cat([pos, x])) instead of after. -
aggr(PoolLike, default:'max') βPooling operation applied per batch element.
PointNet2FeaturePropagation [source] ΒΆ
PointNet2FeaturePropagation(
channels: Sequence[int],
k: int = 3,
dropout: float = 0.0,
act: Union[str, Callable, None] = "relu",
act_first: bool = False,
act_kwargs: Optional[Dict[str, Any]] = None,
norm: Union[str, Callable, None] = "batch_norm",
norm_kwargs: Optional[Dict[str, Any]] = None,
bias: Union[bool, List[bool]] = True,
plain_last: bool = True,
weighting: Literal["squared", "inverse"] = "inverse",
eps: float = 1e-16,
)
Bases: Module
K-NN interpolation + skip concatenation + MLP, as in PointNet++: Deep Hierarchical Feature Learning on Point Sets in a Metric Space.
The interpolated features are concatenated before the skip features (cat([interp, skip])).
Parameters:
-
channels(Sequence[int]) βPer-layer channel sizes of the MLP, starting with its input width (interpolated plus skip channels).
-
k(int, default:3) βNumber of neighbors for the K-NN interpolation. PointNet++ uses \(k = 3\) with inverse-distance weighting; RandLA-Net uses \(k = 1\) (nearest only).
-
dropout(float, default:0.0) βDropout rate inside the MLP.
-
bias(Union[bool, List[bool]], default:True) βWhether the MLP linear layers use a bias.
-
plain_last(bool, default:True) βLeave the last MLP layer without normalization and activation.
-
weighting(Literal['squared', 'inverse'], default:'inverse') βInverse-distance weighting scheme passed to
knn_interpolate. Irrelevant when \(k = 1\). -
eps(float, default:1e-16) βNumerical stability term added to the interpolation distances.