AI Logic

Architectures

PointNet

Updated:

Architecture of PointNet. Left: the flow of the classification network (n points pass through an input transform, a shared MLP, a feature transform, and another shared MLP to become 1024-dimensional each; max pooling turns them into a global feature, from which an MLP predicts the class). Right: how max pooling works (taking the per-channel maximum over the features of 5 points yields the same global feature regardless of the order of the points)

Background and overview

PointNet is a network that takes a 3D point cloud (a set of point coordinates) directly as input, without converting it to a grid or images, applies the same MLP to every point, and aggregates them with a max, producing features that do not depend on the order of the points. It was introduced in 2017 by Qi et al. at Stanford University and accepted at CVPR 2017. A single architecture handles object classification, part segmentation, and semantic segmentation of indoor scenes.

Point clouds obtained from LiDAR or depth cameras are not arranged regularly like pixels. Before PointNet, deep learning typically either packed point clouds into a 3D grid (voxels) and applied 3D convolutions, or rendered them as images from several viewpoints and applied 2D CNNs. However, voxelization makes the data needlessly large and introduces quantization errors from snapping points to the grid.

To handle point clouds directly, a network must respect their properties.

  • No order: nn points form a set, so even though there are n!n! ways to order them, the network must produce the same result for the same point cloud.
  • Nearby points are meaningful: Points live in a space with a distance metric, and groups of nearby points form shapes.
  • Invariance to rotation and translation: Rotating the entire point cloud does not change the object's category.

PointNet satisfies the first property with a simple mechanism, turning each point into a feature with the same MLP and applying max pooling across points, and adds small networks (T-Nets) that align the orientation of the input and the features. On ModelNet40 classification (CAD models of 40 object categories), it reaches 89.2% overall accuracy, outperforming voxel-based 3D CNNs, with far less computation.

Theory: functions that do not depend on order

Basic idea

The paper compares three ways to make the result independent of the order of the input points.

  • Sort into a canonical order: In high-dimensional space, there is in general no ordering that stays stable when points move slightly. Applying an MLP to sorted points still gave low accuracy.
  • Train an RNN on varied orderings: This works reasonably for sequences of a few dozen elements, but it is hard to scale to thousands of points, and its accuracy did not reach PointNet's.
  • Aggregate with a symmetric function: Use a function whose result does not change when its inputs are reordered (a symmetric function), such as sum or max. This is PointNet's approach.

PointNet approximates a function ff on a set of points by combining a function hh applied to each point with a symmetric function gg (Eq. (1) of the paper).

f({x1,…,xn})≈g(h(x1),…,h(xn))f(\{x_1, \dots, x_n\}) \approx g\bigl(h(x_1), \dots, h(x_n)\bigr)

Procedure

  1. Turn each point into a feature: hh is an MLP applied to every point with the same weights (a shared MLP). Point xix_i becomes a KK-dimensional feature h(xi)h(x_i). Since each point is processed independently, order has no effect.
  2. Take the max across points: For each of the KK channels, take the maximum over the nn points. Since max is a symmetric function, reordering the points yields the same KK-dimensional vector. This is the global feature of the point cloud.
  3. Predict from the global feature: Apply an MLP γ\gamma to the global feature to output class scores.

The paper also tried average pooling and an attention-based weighted sum instead of max, and found max to be the best by a large margin.

Universal approximation theorem

The paper shows that this form can approximate any continuous set function (continuous with respect to the Hausdorff distance) arbitrarily well (Theorem 1 of the paper). For any ϵ>0\epsilon > 0, there exist continuous functions hh and γ\gamma such that

∣ f(S)−γ(MAXxi∈S{h(xi)})∣<ϵ\Bigl|\, f(S) - \gamma\Bigl(\underset{x_i \in S}{\mathrm{MAX}} \{h(x_i)\}\Bigr) \Bigr| < \epsilon

holds. MAX is the element-wise maximum. The idea of the proof is that, if the dimension KK of max pooling is large enough, the network can at worst learn the equivalent of partitioning the space into equal-sized voxels.

Critical point set

Each channel of the global feature u=MAXxi∈S{h(xi)}u = \mathrm{MAX}_{x_i \in S}\{h(x_i)\} is determined by a single point. The paper shows the following (Theorem 2 of the paper).

  • A point cloud SS has a subset CSC_S (the critical point set) that determines f(S)f(S): as long as the points of CSC_S remain, removing other points, or adding points within a certain region NSN_S, does not change the value of ff.
  • CSC_S contains at most KK points.

When visualized, the critical point set looks like the skeleton of the object. In effect, PointNet summarizes a shape by a small number of key points.

Max pooling is like a grade sheet that collects only "the top score for each question" from every student's exam. The sheet is the same no matter who hands in their exam in what order, and as long as the students with the top scores (the critical points) are present, it does not change even if others are absent. This is why the result is robust to missing points or extra points.

Architecture

PointNet consists of shared MLPs applied to each point, T-Nets that align orientation, max pooling, and an MLP that predicts from the global feature (Section 4.2 and Figure 2 of the paper). In the figure at the top of the article, the left side shows the flow of the classification network and the right side shows how max pooling removes the order of the points.

Classification network (input: (x,y,z)(x, y, z) of nn points; n=1024n = 1024 for ModelNet40)

  1. Input transform: A T-Net predicts a 3×33 \times 3 transformation matrix, which is multiplied with the coordinates of all points. This brings the point cloud closer to a canonical orientation.
  2. Shared MLP (64, 64): Maps each point to 64 dimensions.
  3. Feature transform: Another T-Net predicts a 64×6464 \times 64 transformation matrix, which is multiplied with the 64-dimensional feature of each point.
  4. Shared MLP (64, 128, 1024): Maps each point to 1024 dimensions.
  5. Max pooling: Takes the maximum across the nn points, producing a 1024-dimensional global feature.
  6. MLP (512, 256, kk): Outputs scores for kk classes from the global feature. Dropout (keep ratio 0.7) is applied before the last fully connected layer (on the 256-dimensional output).

All layers use Batch Normalization and ReLU (except the last layer of each T-Net). A shared MLP applies the same fully connected layer to each point and can be implemented as a convolution with kernel size 1.

T-Net (a small network that aligns orientation)

A T-Net is a miniature PointNet (Appendix C of the paper). It applies a shared MLP (64, 128, 1024) to each point, max-pools, passes the result through fully connected layers (512, 256), and outputs a transformation matrix. The output is initialized to start from the identity matrix. It realizes the idea of the Spatial Transformer, which aligns orientation and position in images, simply by multiplying point coordinates by a matrix.

The 64×6464 \times 64 feature transformation matrix has many degrees of freedom, which makes it hard to train. So a regularization term is added to the loss to keep the transformation matrix AA close to orthogonal (Eq. (2) of the paper, weight 0.001).

Lreg=∥I−AA⊤∥F2L_{\mathrm{reg}} = \bigl\| I - AA^{\top} \bigr\|_F^2

An orthogonal transformation loses no information, so it may rotate or reflect the feature space but never collapses it.

Segmentation network

Outputting a label per point requires both local information around each point and global information about the whole cloud. PointNet concatenates the 1024-dimensional global feature from max pooling with each point's 64-dimensional feature after the feature transform (1088 dimensions), and outputs scores for mm classes per point through shared MLPs (512, 256, 128) and (128, mm). For part segmentation, a one-hot vector representing the object category is also concatenated with the global feature.

Training setup (Appendix C of the paper)

The optimizer is Adam (learning rate 0.001, batch size 32), and the learning rate is halved every 20 epochs. For classification, the data is augmented by random rotation around the up axis and Gaussian noise with standard deviation 0.02 added to each point. Training on ModelNet40 took 3 to 6 hours on a single GTX1080.

Experimental results

Object classification (ModelNet40, 40 classes, 9,843 training and 2,468 test objects. Table 1 of the paper)

MethodInputViewsMean per-class accuracyOverall accuracy
3DShapeNetsVoxels177.384.7
VoxNetVoxels1283.085.9
SubvolumeVoxels2086.089.2
MVCNNImages8090.1—
Hand-crafted features + MLP (paper's baseline)Points—72.677.4
PointNetPoints186.289.2

This is the best result among methods with 3D input (voxels and points). It falls slightly short of MVCNN, which uses images rendered from 80 views; the paper attributes this to rendered images preserving fine shape details.

Computational cost (Table 6 of the paper)

MethodParametersFLOPs per sample
PointNet (without T-Net)0.8M148M
PointNet3.5M440M
Subvolume16.6M3,633M
MVCNN60M62,057M

PointNet's cost grows linearly with the number of points and is 1/141 of MVCNN's and 1/8 of Subvolume's. On a GPU it can process more than 1 million points per second (about 1,000 objects for classification).

Effect of T-Nets (overall accuracy on ModelNet40. Table 5 of the paper)

TransformAccuracy
None87.1
Input transform (3×3) only87.9
Feature transform (64×64) only86.9
Feature transform + orthogonal regularization87.4
Both + regularization89.2

Without regularization, the 64×64 feature transform actually lowered accuracy.

Part segmentation (ShapeNet parts, 16 categories and 50 parts. Per-point mIoU. Table 2 of the paper): PointNet averages 83.7, beating previous methods (81.4) and the paper's 3D CNN baseline (79.4).

Semantic segmentation of indoor scenes (13 classes. Table 3 of the paper): Representing each point with 9 dimensions, (x,y,z)(x, y, z), RGB, and normalized position within the room, PointNet reaches a mean IoU of 47.71 and point accuracy of 78.62, far above the hand-crafted feature baseline (20.12 and 53.19).

Robustness to missing and corrupted input (Figures 6 and 8 of the paper): Even with 50% of the points removed, accuracy drops only from 87.1% to 85.7% when keeping the farthest points and to 83.3% when keeping random points. Under the same conditions, VoxNet drops from 86.3% to 46%. Even with 20% of the points being outliers, PointNet stays above 80% if trained with outliers.

Caveats in practice

Keep the following points in mind when using PointNet.

  • Cannot capture local relations between nearby points hierarchically: Each point becomes a feature independently, and information between points is combined only at the final max pooling. Unlike a CNN, there is no mechanism for building up from small local shapes to larger ones. It struggles with fine-grained shape differences and point clouds whose density varies by location; its successor PointNet++ addresses this by building a hierarchy that applies PointNet to each group of nearby points.
  • Normalize the size and position of point clouds: For classification, points are normalized into the unit sphere before being fed in.
  • Add orthogonal regularization to the feature transform: Without regularization, the 64×64 transformation matrix actually lowered accuracy.
  • Number of points: Classification in the paper is trained with 1024 points. The network itself accepts any number of points, but accuracy may change for point clouds with densities very different from training.
  • Where to get it: The official implementation of the paper is in TensorFlow (charlesq34/pointnet). In PyTorch, it is easy to build following the paper's architecture (see the code example below), and libraries such as PyTorch Geometric also provide point cloud layers.

PointNet's T-Nets help align orientation, but they do not guarantee rotation invariance. Even in the paper's classification training, only rotation around the up axis is added through data augmentation. When handling point clouds rotated in arbitrary directions, add sufficient rotation augmentation or consider methods designed to be rotation invariant.

Comparison with other methods

The following table compares ways of handling 3D shapes with deep learning along the same axes.

MethodInput formHandling of point orderRelations between nearby pointsCost growth
Voxel 3D CNNs (VoxNet, Subvolume)3D gridNo order, since points are packed into a gridHierarchically, with 3D convolutionsCube of the grid size
Multi-view images (MVCNN)Rendered images (up to 80)No order, since rendered as imagesHierarchically, with 2D convolutionsSquare of the image resolution × number of images
PointNetRaw point coordinatesMax pooling (a symmetric function)Only aggregated globally at the endLinear in the number of points
PerceiverAny set of elements (point clouds included)Cross-attention (permutation invariant)Attention over everythingNumber of points × latent array size

PointNet's strengths are that it handles point clouds without conversion, is computationally light, and is robust to missing points and outliers. On the other hand, because it cannot capture local shapes hierarchically, it can fall behind voxel and multi-view methods, as well as later hierarchical methods, at distinguishing fine shapes. In the ModelNet40 comparison in the Perceiver paper, the general-purpose Perceiver scores 85.7%, short of PointNet's successor PointNet++ (91.9%).

Rough guidelines for choosing a method:

  • To classify and segment point clouds quickly and cheaply: PointNet is the starting point. Its architecture is simple and lightweight to implement.
  • To distinguish fine shape differences or handle point clouds with varying density: Consider hierarchical methods such as PointNet++, which build features step by step from groups of nearby points.
  • To handle point clouds together with images, audio, and so on in one model: General-purpose attention models such as Perceiver are suitable.

PyTorch example

Show code
python
import torch
import torch.nn as nn
import torch.nn.functional as F

"""
A small implementation of PointNet's classification network (Figure 2 and Appendix C of the paper).
Shared MLPs are written as Conv1d with kernel size 1 (equivalent to applying the same fully connected layer to every point).
"""


def shared_mlp(sizes):
  layers = []
  for c_in, c_out in zip(sizes[:-1], sizes[1:]):
    layers += [nn.Conv1d(c_in, c_out, 1), nn.BatchNorm1d(c_out), nn.ReLU()]
  return nn.Sequential(*layers)


class TNet(nn.Module):
  """A small PointNet that predicts a k×k transformation matrix. The output starts from the identity matrix"""

  def __init__(self, k):
    super().__init__()
    self.k = k
    self.mlp = shared_mlp([k, 64, 128, 1024])
    self.fc = nn.Sequential(nn.Linear(1024, 512), nn.BatchNorm1d(512), nn.ReLU(),
                            nn.Linear(512, 256), nn.BatchNorm1d(256), nn.ReLU(),
                            nn.Linear(256, k * k))
    nn.init.zeros_(self.fc[-1].weight)
    nn.init.zeros_(self.fc[-1].bias)                       # starts as identity + 0

  def forward(self, x):                                    # x: [B, k, n]
    g = self.mlp(x).max(dim=2).values                      # max across points -> [B, 1024]
    eye = torch.eye(self.k, device=x.device).flatten()
    return (self.fc(g) + eye).view(-1, self.k, self.k)     # [B, k, k]


class PointNetCls(nn.Module):
  def __init__(self, num_classes=40):
    super().__init__()
    self.input_tnet = TNet(3)                              # input transform 3×3
    self.mlp1 = shared_mlp([3, 64, 64])
    self.feature_tnet = TNet(64)                           # feature transform 64×64
    self.mlp2 = shared_mlp([64, 64, 128, 1024])
    self.head = nn.Sequential(nn.Linear(1024, 512), nn.BatchNorm1d(512), nn.ReLU(),
                              nn.Linear(512, 256), nn.BatchNorm1d(256), nn.ReLU(),
                              nn.Dropout(p=0.3),            # keep ratio 0.7
                              nn.Linear(256, num_classes))

  def forward(self, pts):                                  # pts: [B, n, 3] (any order)
    x = pts.transpose(1, 2)                                # [B, 3, n]
    T1 = self.input_tnet(x)
    x = torch.bmm(T1, x)                                   # multiply coordinates by the 3×3 matrix
    x = self.mlp1(x)                                       # [B, 64, n]
    A = self.feature_tnet(x)
    x = torch.bmm(A, x)                                    # multiply features by the 64×64 matrix
    x = self.mlp2(x)                                       # [B, 1024, n]
    g = x.max(dim=2).values                                # symmetric function: max across points
    return self.head(g), A


def orthogonal_reg(A):
  """Eq. (2): L_reg = ||I - A A^T||_F^2"""
  eye = torch.eye(A.shape[1], device=A.device)
  return ((eye - torch.bmm(A, A.transpose(1, 2))) ** 2).sum(dim=(1, 2)).mean()


model = PointNetCls(num_classes=40)
model.train()                                              # Dropout and BatchNorm behave differently in train and eval
pts = torch.randn(8, 1024, 3)
labels = torch.randint(0, 40, (8,))
logits, A = model(pts)
loss = F.cross_entropy(logits, labels) + 0.001 * orthogonal_reg(A)
loss.backward()

model.eval()                                               # inference: Dropout off, BatchNorm uses running averages
with torch.no_grad():
  perm = torch.randperm(1024)
  out1, _ = model(pts)
  out2, _ = model(pts[:, perm])                            # even if the points are reordered
  print(torch.allclose(out1, out2, atol=1e-5))             # True: the output is the same

FAQ

Q. Why does PointNet produce the same result regardless of the order of the points?
A.

Because it applies the same MLP independently to each point and aggregates by taking the max across points. Max is a symmetric function whose result does not change when its inputs are reordered. So no matter in what order the nn points are fed in, the global feature is the same 1024-dimensional vector. In the paper's comparison, max beat average pooling, an attention-based weighted sum, an MLP on sorted points, and an RNN by a large margin.

Q. What does the T-Net do?
A.

It is a small PointNet that predicts, from the input, a transformation matrix for aligning the orientation of the point cloud or the features. A 3×33 \times 3 matrix is multiplied with the input point coordinates, and a 64×6464 \times 64 matrix with the intermediate 64-dimensional features. Because the 64×6464 \times 64 matrix has many degrees of freedom, a regularization term ∥I−AA⊤∥F2\|I - AA^{\top}\|_F^2 that pushes it toward an orthogonal matrix is added to the loss. On ModelNet40, the two transforms plus regularization raise accuracy from 87.1% to 89.2%.

Q. What are PointNet's weaknesses?
A.

It cannot build up small local shapes formed by nearby points step by step. Each point becomes a feature independently, and information between points is combined only at the final max pooling. As a result, it struggles with fine-grained shape distinctions and point clouds whose density varies by location. Its successor PointNet++ addresses this weakness by building a hierarchy that applies PointNet to each group of nearby points.

References

  1. Qi, C. R., Su, H., Mo, K., & Guibas, L. J. (2017). PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation. CVPR 2017. arXiv:1612.00593.
  2. charlesq34/pointnet (official implementation).
  3. Qi, C. R., Yi, L., Su, H., & Guibas, L. J. (2017). PointNet++: Deep Hierarchical Feature Learning on Point Sets in a Metric Space. arXiv:1706.02413.