RandLA-Net
RandLA-Net classification and segmentation models.

Classes:
-
RandLANetIntermediate–Per-stage encoder features, positions and batch index, kept for the decoder skip connections.
-
LocalSpatialEncoding–Per-edge spatial encoding MLP (RandLA-Net Section 3.2).
-
AttentivePooling–Attention-weighted aggregation of pre-gathered edge features (RandLA-Net Section 3.3).
-
LocalFeatureAggregation–Local Feature Aggregation module (RandLA-Net Section 3.4).
-
DilatedResidualBlock–RandLA-Net dilated residual block (Fig. 3 of the paper).
-
RandLANetEncoder–Stack of
DilatedResidualBlockunits interleaved with random-sampling -
RandLANetDecoder–Stack of
PointNet2FeaturePropagationblocks specialized to RandLA-Net. -
RandLANetClassification–RandLA-Net classification model from
-
RandLANetSegmentation–RandLA-Net segmentation model from
Functions:
-
random_max_pool–Random sampling followed by a max-pool over the neighbors of each kept point.
RandLANetIntermediate
¶
Bases: NamedTuple
Per-stage encoder features, positions and batch index, kept for the decoder skip connections.
LocalSpatialEncoding
¶
LocalSpatialEncoding(
in_channels: int,
out_channels: int,
*,
act: Union[str, Callable, None],
act_kwargs: Optional[Dict[str, Any]] = None,
act_first: bool = False,
norm: Union[str, Callable, None],
norm_kwargs: Optional[Dict[str, Any]] = None,
bias: bool = False,
)
Bases: Module
Per-edge spatial encoding MLP (RandLA-Net Section 3.2).
Wraps a single Linear+norm+act block that lifts an input feature to out_channels.
Used twice per LocalFeatureAggregation: first on the raw 10-channel relative
positional encoding, then on its output.
AttentivePooling
¶
AttentivePooling(
in_channels: int,
out_channels: int,
*,
act: Union[str, Callable, None],
act_kwargs: Optional[Dict[str, Any]] = None,
act_first: bool = False,
norm: Union[str, Callable, None],
norm_kwargs: Optional[Dict[str, Any]] = None,
bias: bool = False,
)
Bases: Module
Attention-weighted aggregation of pre-gathered edge features (RandLA-Net Section 3.3).
Given \((E, C)\) edge features and a per-edge destination index, learn per-edge
attention scores via a no-bias linear layer, softmax-normalize them across the
neighbors of each destination point, sum the score-weighted features per
destination, then project the result with a Linear+norm+act block.
Parameters:
-
in_channels(int) –Channels of each edge feature.
-
out_channels(int) –Output channels after the post-aggregation MLP.
LocalFeatureAggregation
¶
LocalFeatureAggregation(
d_out: int,
*,
act: Union[str, Callable, None],
act_kwargs: Optional[Dict[str, Any]] = None,
act_first: bool = False,
norm: Union[str, Callable, None],
norm_kwargs: Optional[Dict[str, Any]] = None,
bias: bool = False,
)
Bases: Module
Local Feature Aggregation module (RandLA-Net Section 3.4).
Stacks two LocalSpatialEncoding + AttentivePooling units to progressively grow
the receptive field, doubling a per-point feature of dim \(d_\text{out} / 2\) to
\(d_\text{out}\). Mirrors the LocSE + Attentive Pooling "dilated" combination in
Fig. 3 of the paper. The 10-channel relative positional encoding follows the
original QingyongHu/RandLA-Net channel
order (cat([rel_dist, rel_xyz, xyz_i, xyz_j], dim=-1)) so pretrained weights load
without permuting the first 1x1 kernel. The second LSE re-projects the output of
the first LSE to match the original building_block.
DilatedResidualBlock
¶
DilatedResidualBlock(
d_in: int,
d_out: int,
num_neighbors: int,
*,
act: Union[str, Callable, None],
act_kwargs: Optional[Dict[str, Any]] = None,
act_first: bool = False,
norm: Union[str, Callable, None],
norm_kwargs: Optional[Dict[str, Any]] = None,
bias: bool = False,
)
Bases: Module
RandLA-Net dilated residual block (Fig. 3 of the paper).
Maps d_in channels to \(2 \cdot d_\text{out}\) via a residual path of
MLP -> LocalFeatureAggregation -> MLP plus a parallel Linear+norm shortcut.
The sum is activated by the configured activation. mlp2 and shortcut skip the
activation (paper-mandated: Conv2d(activation=False) upstream); the configured
activation is applied once after the residual sum.
Parameters:
-
d_in(int) –Number of input channels.
-
d_out(int) –"Configuration" channel count; the block actually outputs \(2 \cdot d_\text{out}\).
-
num_neighbors(int) –Number of neighbors for the local feature aggregation.
RandLANetEncoder
¶
RandLANetEncoder(
in_channels: int,
encoder_channels: Sequence[int],
decimation: Union[int, Sequence[int]] = 4,
num_neighbors: Union[int, Sequence[int]] = 16,
*,
act: Union[str, Callable, None],
act_kwargs: Optional[Dict[str, Any]] = None,
act_first: bool = False,
norm: Union[str, Callable, None],
norm_kwargs: Optional[Dict[str, Any]] = None,
bias: bool = False,
)
Bases: Module
Stack of DilatedResidualBlock units interleaved with random-sampling
K-NN max-pool decimation (RandLA-Net Section 3 / Fig. 2).
Each encoder block doubles its \(d_\text{out}^\text{config}\) to produce a \(2 \cdot d_\text{out}^\text{config}\) channel feature; the per-stage decimation ratio then sub-samples the cloud by that factor.
When return_intermediates=True is passed to forward, the encoder returns the
bottleneck features plus the per-stage skip features in fine-to-coarse order:
intermediates[0] is block 0's PRE-decimation output (used as the full-resolution
skip in RandLANetDecoder); subsequent entries are the POST-decimation outputs of
blocks \(0 \ldots N-2\). The decoder consumes them in reverse.
Parameters:
-
in_channels(int) –Number of input channels.
-
encoder_channels(Sequence[int]) –Output channels of each dilated residual block (must be even).
-
decimation(Union[int, Sequence[int]], default:4) –Decimation factor between consecutive encoder blocks. Either a single
intor a per-block sequence of length \(N\). -
num_neighbors(Union[int, Sequence[int]], default:16) –Number of neighbors for the K-NN graph in each block. Either a single
intor a per-block sequence of length \(N\).
RandLANetDecoder
¶
RandLANetDecoder(
in_channels: int,
skip_channels: Sequence[int],
fp_channels: Sequence[int],
*,
act: Union[str, Callable, None],
act_kwargs: Optional[Dict[str, Any]] = None,
act_first: bool = False,
norm: Union[str, Callable, None],
norm_kwargs: Optional[Dict[str, Any]] = None,
bias: bool = False,
)
Bases: Module
Stack of PointNet2FeaturePropagation blocks specialized to RandLA-Net.
Each block does 1-NN upsampling from the deeper resolution to its pos_skip
resolution, concatenates with the encoder skip features, then applies a single
linear+norm+act projection. The first block consumes the bottleneck features
and the deepest encoder skip; subsequent blocks each cut the resolution by a
stage of decimation until the finest (full-resolution) skip is reached.
Note
Upstream RandLA-Net cats [skip, interp] while
PointNet2FeaturePropagation cats [interp, skip]. To preserve weight
equivalence with the upstream checkpoint, the conversion utilities
(convert_randlanet_state_dict, convert_open3d_randlanet_state_dict)
swap the first linear layer's column blocks per FP block.
Parameters:
-
in_channels(int) –Channels at the bottleneck (input to the first FP).
-
skip_channels(Sequence[int]) –Per-stage encoder skip channels in coarse-to-fine order.
-
fp_channels(Sequence[int]) –Per-stage decoder output channels (same length as
skip_channels). -
act(Union[str, Callable, None]) –Activation passed to each
PointNet2FeaturePropagationMLP. -
act_kwargs(Optional[Dict[str, Any]], default:None) –Activation kwargs.
-
act_first(bool, default:False) –If
True, activation is applied before normalization. -
norm(Union[str, Callable, None]) –Normalization passed to each
PointNet2FeaturePropagationMLP. -
norm_kwargs(Optional[Dict[str, Any]], default:None) –Normalization kwargs.
-
bias(bool, default:False) –Whether to use bias in the MLP layers.
Note
No paper-specific defaults are baked in here; callers (typically the registered model factory) supply them.
RandLANetClassification
¶
RandLANetClassification(
in_channels: int,
num_classes: int,
*,
stem_channels: Optional[int] = 8,
encoder_channels: Sequence[int],
decimation: Union[int, Sequence[int]] = 4,
num_neighbors: Union[int, Sequence[int]] = 16,
aggr_channels: Optional[
Union[int, Sequence[int]]
] = None,
dropout: float = 0.0,
global_pool: PoolLike = "max",
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,
)
Bases: ClassificationModel
RandLA-Net classification model from RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds by Qingyong Hu, Bo Yang, Linhai Xie, Stefano Rosa, Yulan Guo, Zhihua Wang, Niki Trigoni, Andrew Markham.
Random sampling for downsampling and dilated residual blocks with local feature aggregation; point features are pooled globally after the encoder for classification.
Parameters:
-
in_channels(int) –Number of input channels.
-
num_classes(int) –Number of classes.
-
stem_channels(Optional[int], default:8) –Number of channels in the stem MLP. Set to
Noneto skip the stem. -
encoder_channels(Sequence[int]) –Output channels of each dilated residual block (must be even).
-
decimation(Union[int, Sequence[int]], default:4) –Decimation factor between consecutive encoder blocks.
-
num_neighbors(Union[int, Sequence[int]], default:16) –Number of neighbors for the kNN graph in each block.
-
aggr_channels(Optional[Union[int, Sequence[int]]], default:None) –Optional channels for the aggregation MLP applied before global pooling.
-
dropout(float, default:0.0) –Dropout rate before the classification head.
-
global_pool(PoolLike, default:'max') –Global pooling operation.
Methods:
-
configure_stem–Build the stem lifting the input features to
stem_channels, orNonewhenstem_channelsis unset. -
configure_encoder–Build the
RandLANetEncoderbackbone. -
configure_aggr–Build the aggregation MLP applied to the encoder output, or
Nonewhenaggr_channelsis unset.
Attributes:
-
num_features(int) –Feature dimension \(C\) of the encoder output, after the optional aggregation MLP.
num_features
property
¶
Feature dimension \(C\) of the encoder output, after the optional aggregation MLP.
configure_stem
¶
Build the stem lifting the input features to stem_channels, or None when stem_channels is unset.
configure_aggr
¶
Build the aggregation MLP applied to the encoder output, or None when aggr_channels is unset.
RandLANetSegmentation
¶
RandLANetSegmentation(
in_channels: int,
num_classes: int,
*,
stem_channels: Optional[int] = 8,
encoder_channels: Sequence[int],
fp_channels: Sequence[int],
head_channels: Sequence[int] = (64, 32),
decimation: Union[int, Sequence[int]] = 4,
num_neighbors: Union[int, Sequence[int]] = 16,
aggr_channels: Optional[
Union[int, Sequence[int]]
] = None,
dropout: float = 0.5,
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,
)
Bases: SegmentationModel
RandLA-Net segmentation model from RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds by Qingyong Hu, Bo Yang, Linhai Xie, Stefano Rosa, Yulan Guo, Zhihua Wang, Niki Trigoni, Andrew Markham.
Encoder uses random sampling between dilated residual blocks; decoder uses 1-NN nearest-neighbor interpolation with concatenation skips and a single 1x1 linear+BN+act per stage. The skip used at full resolution is the pre-decimation output of the first encoder block.
Parameters:
-
in_channels(int) –Number of input channels.
-
num_classes(int) –Number of classes.
-
stem_channels(Optional[int], default:8) –Number of channels in the stem MLP. Set to
Noneto skip the stem. -
encoder_channels(Sequence[int]) –Output channels of each dilated residual block (must be even).
-
fp_channels(Sequence[int]) –Per-stage decoder channels (one list per upsampling step).
-
head_channels(Sequence[int], default:(64, 32)) –Hidden channels of the segmentation head MLP.
-
decimation(Union[int, Sequence[int]], default:4) –Decimation factor between consecutive encoder blocks.
-
num_neighbors(Union[int, Sequence[int]], default:16) –Number of neighbors for the kNN graph in each block.
-
aggr_channels(Optional[Union[int, Sequence[int]]], default:None) –Channels for the bottleneck MLP between the encoder and the decoder (the upstream "decoder_0").
-
dropout(float, default:0.5) –Dropout rate inside the segmentation head MLP.
-
act(Union[str, Callable, None], default:'relu') –Activation type for both the decoder FP MLPs and the segmentation head MLP (string passed to
create_act, or aCallable/nn.Module). -
act_kwargs(Optional[Dict[str, Any]], default:None) –Keyword arguments forwarded to the activation.
-
act_first(bool, default:False) –If
True, apply activation before normalization (PyG's MLPact_firstsemantics):Linear → Act → Norm → Dropoutinstead of the defaultLinear → Norm → Act → Dropout. -
norm(Union[str, Callable, None], default:'batch_norm') –Normalization type for the decoder FP MLPs and the head MLP.
-
norm_kwargs(Optional[Dict[str, Any]], default:None) –Keyword arguments forwarded to the normalization layers.
-
bias(bool, default:False) –Whether the decoder/head hidden linear layers carry an explicit bias. The final head layer always uses
bias=Truesince it has no normalization.
Methods:
-
configure_stem–Build the stem lifting the input features to
stem_channels, orNonewhenstem_channelsis unset. -
configure_encoder–Build the
RandLANetEncoderbackbone. -
configure_aggr–Build the aggregation MLP applied to the encoder output, or
Nonewhenaggr_channelsis unset. -
configure_decoder–Build the
RandLANetDecoderupsampling the bottleneck features back through the encoder skips.
Attributes:
-
num_features(int) –Feature dimension \(C\) of the decoder output.
configure_stem
¶
Build the stem lifting the input features to stem_channels, or None when stem_channels is unset.
configure_aggr
¶
Build the aggregation MLP applied to the encoder output, or None when aggr_channels is unset.
configure_decoder
¶
configure_decoder() -> RandLANetDecoder
Build the RandLANetDecoder upsampling the bottleneck features back through the encoder skips.
random_max_pool
¶
random_max_pool(
x: Tensor,
pos: Tensor,
batch: Tensor,
factor: int,
num_neighbors: int,
generator: Optional[Generator] = None,
) -> Tuple[Tensor, Tensor, Tensor]
Random sampling followed by a max-pool over the neighbors of each kept point.
Parameters:
-
x(Tensor) –Packed point features, shape \((N, C)\).
-
pos(Tensor) –Packed point positions, shape \((N, 3)\).
-
batch(Tensor) –Per-point batch index, shape \((N,)\).
-
factor(int) –Decimation factor, keeping \(N // \text{factor}\) points per cloud.
-
num_neighbors(int) –Number of neighbors gathered around each kept point.
-
generator(Optional[Generator], default:None) –Generator driving the random sampling.
Returns:
-
Tuple[Tensor, Tensor, Tensor]–The pooled features, positions and batch index of the kept points.