学术
模块更新于 2026-11-20· 浏览 8· 下载 5

DSA 分解式集合抽象

空间通道解耦:借鉴 MobileNet,用两条独立 MLP 分别学点级语义特征(c→c)和邻域几何特征(3→c),几何特征作为偏置加到邻居语义特征上再最大池化;与原 SA 前向数学等价

三维视觉三维视觉点云语义分割DSANeurIPS2024

结构图

DSA 分解式集合抽象结构图
DSA 分解式集合抽象结构图

空间通道解耦:借鉴 MobileNet,用两条独立 MLP 分别学点级语义特征(c→c)和邻域几何特征(3→c),几何特征作为偏置加到邻居语义特征上再最大池化;与原 SA 前向数学等价

论文信息

  • 论文:LinNet: Linear Network for Efficient Point Cloud Representation Learning
  • 出处:NeurIPS 2024

核心痛点

PointNet++ 系 SA 模块把邻居语义特征和相对坐标拼接后用同一个共享 MLP 处理,高维语义变换要对每个邻居重复计算,复杂度随邻居数 k 膨胀;邻域搜索依赖 FPS+KNN,在 PointNeXt 里占 46% 的运行时间,大场景下又慢又吃显存。

模块亮点

  • 空间通道解耦:借鉴 MobileNet,用两条独立 MLP 分别学点级语义特征(c→c)和邻域几何特征(3→c),几何特征作为偏置加到邻居语义特征上再最大池化;与原 SA 前向数学等价
  • 消融涨点明确:S3DIS Area5 同一框架下,DSA 拿到 73.1 mIoU,比 Vanilla SA 高 1.1,比 ASSA 高 2.6、比 PosPool 高 3.2
  • 省算力降显存:语义特征只按点变换,局部聚合复杂度从 kc² 降到 c²,FLOPs 远低于 SA,训练 / 推理显存也明显下降

适用场景

领域为 3D 点云理解 / 大场景语义分割,原文在 S3DIS、NuScenes、SemanticKITTI 上验证(整体 LinNet mIoU 73.7 / 81.4 / 69.1);可迁移到点云目标检测等 PointNet++ 式局部聚合网络。

插入位置建议

  • 直接替换 PointNeXt、PointNet++ 等分层点云网络中的 SA / 局部聚合模块
  • 作为编码器每个 stage 的基础块,放在下采样层之后堆叠使用
  • 搭配线性化采样等线性复杂度搜索策略,大场景下提速更彻底

适用任务

  • 3D 点云理解
  • 大场景语义分割
  • 原文在 S3DIS

完整代码

dsa.py
from typing import List, Type, Tuple
import torch
import torch.nn as nn


class PointBatchNorm(nn.Module):
    """
    Batch Normalization for Point Clouds data in shape of [B*N, C], [B*N, L, C]
    """

    def __init__(self, embed_channels):
        super().__init__()
        self.norm = nn.BatchNorm1d(embed_channels)

    def forward(self, input: torch.Tensor) -> torch.Tensor:
        if input.dim() == 3:
            return (
                self.norm(input.transpose(1, 2).contiguous())
                    .transpose(1, 2)
                    .contiguous()
            )
        elif input.dim() == 2:
            return self.norm(input)
        else:
            raise NotImplementedError


def create_linear_block1d(in_channels: int,
                          out_channels: int,
                          bn: bool = True,
                          act: bool = True
                          ) -> nn.Sequential:
    """
    Linear -> [BatchNorm] -> [ReLU]
    """
    layers: List[nn.Module] = [nn.Linear(in_channels, out_channels)]
    if bn:
        layers.append(PointBatchNorm(out_channels))
    if act:
        layers.append(nn.ReLU(inplace=True))
    return nn.Sequential(*layers)


class DSA(nn.Module):
    def __init__(self,
                 in_channels,
                 out_channels,
                 expanse=1,
                 ):
        super().__init__()
        self.pre = create_linear_block1d(in_channels, out_channels)
        self.pool = lambda x: torch.max(x, dim=-2, keepdim=False)[0]
        self.bn = nn.BatchNorm1d(out_channels)

        # feed-forward network
        c = [out_channels, out_channels * expanse, out_channels]
        layers = [
            create_linear_block1d(c[i], c[i+1], act=(i < len(c)-2))
            for i in range(len(c)-1)
        ]
        self.ffn = nn.Sequential(*layers)
        self.act = nn.ReLU(inplace=True)

    def forward(self, inputs):
        p, f, pe, knn_index = inputs
        identity = f
        f = self.pre(f)
        f = self.bn(self.pool(pe + f[knn_index]))

        f = self.ffn(f)

        f = identity + f
        f = self.act(f)
        return [p, f, pe, knn_index]


if __name__ == "__main__":
    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    print("Device:", device)

    # ---- test shapes ----
    B = 2
    N = 1024
    BN = B * N
    C = 64          # set in_channels == out_channels to make residual add valid
    K = 16
    expanse = 2

    block = DSA(in_channels=C, out_channels=C, expanse=expanse).to(device)
    block.train()

    # p: 点云坐标
    p = torch.randn(BN, 3, device=device)

    # f: features [BN, C]
    f = torch.randn(BN, C, device=device)

    # knn_index: [BN, K], each row contains neighbor indices in [0, BN-1]
    knn_index = torch.randint(low=0, high=BN, size=(BN, K), device=device, dtype=torch.long)

    # pe: positional encoding / edge feature, broadcastable with f[knn_index] = [BN, K, C]
    pe = torch.randn(BN, K, C, device=device)

    out = block([p, f, pe, knn_index])
    p_out, f_out, pe_out, knn_out = out

    print("Input shapes:")
    print("  p        :", p.shape)
    print("  f        :", f.shape)
    print("  pe       :", pe.shape)
    print("  knn_index:", knn_index.shape, knn_index.dtype)

    print("Output shapes:")
    print("  p_out    :", p_out.shape)  # 点云坐标
    print("  f_out    :", f_out.shape)  # 更新后的点特征 f
    print("  pe_out   :", pe_out.shape)  # 位置编码
    print("  knn_out  :", knn_out.shape, knn_out.dtype)  # KNN邻接索引

环境与依赖

Python 3.9+

继续浏览

下一篇DSCVolumeReg 3D深度可分离代价体正则化模块3D深度可分离卷积:把普通 3D 卷积拆成 depthwise + pointwise 两级,沿深度维和空间维分别聚合代价;K=3、Ĉ=32 时计算量约为普通 3D 卷积的 1/14

相关资源