point_mamba
Point-Mamba classification and masked autoencoder pretraining models.

Classes:
-
PointMambaEncoderMAEβPointMamba encoder for masked-autoencoder pre-training.
-
PointMambaDecoderMAEβPointMamba decoder for masked-autoencoder pre-training.
-
PointMambaClassificationβ -
PointMambaPretrainingβPointMamba masked-autoencoder pre-training model, as described in the paper PointMamba: A Simple State Space Model for Point Cloud Analysis.
Functions:
-
order_sortβSort points along a space-filling curve, so a state space model scans spatially close points in sequence.
PointMambaEncoderMAE [source] ΒΆ
PointMambaEncoderMAE(
in_channels: int,
embed_dim: int,
depth: int,
num_groups: int,
group_size: int,
mask_ratio: float,
drop_path: float = 0.0,
spatial_dim: int = 3,
patch_local_channels: Sequence[int] = (128, 256),
patch_global_channels: Sequence[int] = (512,),
pos_embed_channels: Sequence[int] = (128,),
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: Union[bool, List[bool]] = True,
)
Bases: Module
PointMamba encoder for masked-autoencoder pre-training.
Embeds patches, serializes them along a randomly chosen Hilbert or Trans-Hilbert curve, masks a fraction of the patch tokens, and processes only the visible tokens with the Mamba blocks. The forward pass returns a dict with the visible-token features, the densified patch positions and reconstruction targets, and the visible / masked token indices.
Parameters:
-
in_channels(int) βThe number of input channels.
-
embed_dim(int) βThe number of token channels.
-
depth(int) βThe number of Mamba blocks.
-
num_groups(int) βThe number of patches to sample.
-
group_size(int) βThe number of neighbors to consider for each patch.
-
mask_ratio(float) βThe fraction of patch tokens to mask.
-
drop_path(float, default:0.0) βThe maximum stochastic-depth rate, linearly scaled across the Mamba blocks.
-
spatial_dim(int, default:3) βThe dimension of the spatial features.
-
patch_local_channels(Sequence[int], default:(128, 256)) βHidden widths of the patch embedder's per-point MLP.
-
patch_global_channels(Sequence[int], default:(512,)) βHidden widths of the patch embedder's per-patch MLP.
-
pos_embed_channels(Sequence[int], default:(128,)) βHidden widths of the positional-embedding MLP.
-
act(Union[str, Callable, None], default:'relu') βThe activation function to use.
-
act_kwargs(Optional[Dict[str, Any]], default:None) βThe keyword arguments to pass to the activation function.
-
act_first(bool, default:False) βWhether to apply the activation function before the normalization.
-
norm(Union[str, Callable, None], default:'batch_norm') βThe normalization function to use.
-
norm_kwargs(Optional[Dict[str, Any]], default:None) βThe keyword arguments to pass to the normalization function.
-
bias(Union[bool, List[bool]], default:True) βWhether to use bias in the MLPs.
Shape
- Input: \((N, C_\text{in})\) features (or
None), \((N, 3)\) coordinates, and a \((N,)\) batch index. - Output: a dict with
x_vis\((B, V, C)\),pos_dense\((B, P, 3)\),target_pos_dense\((B, P, M, 3)\),mask_idx\((B, P - V)\),vis_idx\((B, V)\), and the number of patches \(P\).
PointMambaDecoderMAE [source] ΒΆ
PointMambaDecoderMAE(
embed_dim: int,
depth: int,
drop_path: float,
spatial_dim: int = 3,
pos_embed_channels: Sequence[int] = (128,),
bias: Union[bool, List[bool]] = True,
)
Bases: Module
PointMamba decoder for masked-autoencoder pre-training.
Scatters the visible-token features into a full-length sequence of learnable mask tokens, adds the positional embedding of every patch center, and refines the sequence with a stack of Mamba blocks.
Parameters:
-
embed_dim(int) βThe number of token channels.
-
depth(int) βThe number of Mamba blocks.
-
drop_path(float) βThe maximum stochastic-depth rate, linearly scaled across the Mamba blocks.
-
spatial_dim(int, default:3) βThe dimension of the spatial features.
-
pos_embed_channels(Sequence[int], default:(128,)) βHidden widths of the positional-embedding MLP.
-
bias(Union[bool, List[bool]], default:True) βWhether to use bias in the MLPs.
Shape
- Input:
x_vis\((B, V, C)\),pos_dense\((B, P, 3)\), andids_keep\((B, V)\). - Output: \((B, P, C)\).
PointMambaClassification [source] ΒΆ
PointMambaClassification(
in_channels: int,
num_classes: int,
*,
embed_dim: int = 384,
depth: int = 12,
num_groups: int = 64,
group_size: int = 32,
drop_path: float = 0.1,
use_cls_token: bool = False,
spatial_dim: int = 3,
patch_local_channels: Sequence[int] = (128, 256),
patch_global_channels: Sequence[int] = (512,),
pos_embed_channels: Sequence[int] = (128,),
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: Union[bool, List[bool]] = True,
dropout: float = 0.5,
global_pool: AdaptivePoolLike = "mean",
head_channels: Optional[
Union[int, Sequence[int]]
] = None,
)
Bases: ClassificationModel
Methods:
-
configure_encoderβBuild the
PointMambaEncoderbackbone.
Attributes:
-
num_features(int) βChannel count \(C\) of the pooled features entering the head.
PointMambaPretraining [source] ΒΆ
PointMambaPretraining(
in_channels: int,
*,
embed_dim: int = 384,
encoder_depth: int = 12,
decoder_depth: int = 4,
num_groups: int = 64,
group_size: int = 32,
mask_ratio: float = 0.6,
drop_path: float = 0.1,
spatial_dim: int = 3,
patch_local_channels: Sequence[int] = (128, 256),
patch_global_channels: Sequence[int] = (512,),
pos_embed_channels: Sequence[int] = (128,),
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: Union[bool, List[bool]] = True,
)
Bases: PretrainingModel
PointMamba masked-autoencoder pre-training model, as described in the paper PointMamba: A Simple State Space Model for Point Cloud Analysis. This implementation is adapted from the official repository LMD0311/PointMamba.
Masks a fraction of the serialized patch tokens, encodes the visible tokens with Mamba blocks, reconstructs the masked patches' relative coordinates with a Mamba decoder and a linear head, and returns the predicted and target patch coordinates, each packed with the patch index of its points, for a set-to-set reconstruction objective such as chamfer_distance from torch_pointcloud.losses.
Parameters:
-
in_channels(int) βThe number of input channels.
-
embed_dim(int, default:384) βThe number of token channels.
-
encoder_depth(int, default:12) βThe number of encoder Mamba blocks.
-
decoder_depth(int, default:4) βThe number of decoder Mamba blocks.
-
num_groups(int, default:64) βThe number of patches to sample.
-
group_size(int, default:32) βThe number of neighbors to consider for each patch.
-
mask_ratio(float, default:0.6) βThe fraction of patch tokens to mask.
-
drop_path(float, default:0.1) βThe maximum stochastic-depth rate, linearly scaled across the Mamba blocks.
-
spatial_dim(int, default:3) βThe dimension of the spatial features.
-
patch_local_channels(Sequence[int], default:(128, 256)) βHidden widths of the patch embedder's per-point MLP.
-
patch_global_channels(Sequence[int], default:(512,)) βHidden widths of the patch embedder's per-patch MLP.
-
pos_embed_channels(Sequence[int], default:(128,)) βHidden widths of the positional-embedding MLPs.
-
act(Union[str, Callable, None], default:'relu') βThe activation function to use.
-
act_kwargs(Optional[Dict[str, Any]], default:None) βThe keyword arguments to pass to the activation function.
-
act_first(bool, default:False) βWhether to apply the activation function before the normalization.
-
norm(Union[str, Callable, None], default:'batch_norm') βThe normalization function to use.
-
norm_kwargs(Optional[Dict[str, Any]], default:None) βThe keyword arguments to pass to the normalization function.
-
bias(Union[bool, List[bool]], default:True) βWhether to use bias in the MLPs.
Shape
- Input: \((N, C_\text{in})\) features (or
None), \((N, 3)\) coordinates, and a \((N,)\) batch index. - Output: predicted and target patches, each of shape \((B \cdot M_\text{mask}, \text{group\_size}, 3)\).
Methods:
-
configure_encoderβBuild the
PointMambaEncoderMAEbackbone, which encodes only the visible patches. -
configure_decoderβBuild the
PointMambaDecoderMAEthat reconstructs the masked patches.
configure_encoder [source] ΒΆ
configure_encoder() -> PointMambaEncoderMAE
Build the PointMambaEncoderMAE backbone, which encodes only the visible patches.
configure_decoder [source] ΒΆ
configure_decoder() -> PointMambaDecoderMAE
Build the PointMambaDecoderMAE that reconstructs the masked patches.
order_sort [source] ΒΆ
Sort points along a space-filling curve, so a state space model scans spatially close points in sequence.
Parameters:
-
pos_grid(Tensor) βNon-negative integer grid coordinates of shape \((N, 3)\).
-
batch(Tensor) βPer-point batch index of shape \((N,)\).
-
order(SerializationOrder) βSpace-filling curve to encode the coordinates along.
Returns:
-
TensorβThe permutation of shape \((N,)\) that sorts the points by their serialization code.
Raises:
-
ValueErrorβIf
pos_gridholds a negative coordinate, which would silently wrap around to a valid code.