Concept units

PointNet pooling: one summary for a set

Advanced

Read these first if they are new to you

The idea in one paragraph

PointNet turns a point cloud into one vector of fixed size that does not depend on the order of the points. It applies the same small MLP to every point, which gives each point a vector of features. Then, for each feature, it keeps the largest value over all the points. This step is called max pooling. The result has the same size for 100 points or 100,000, and shuffling the points cannot change it.

A classifier needs one fixed-size vector, but a cloud has any size and no order

Say a network must name the object a point cloud shows: chair, lamp or plane. Its last layers expect one input vector of a fixed size. A cloud, though, can hold 500 points or 50,000, listed in any order. Writing all the coordinates into one long vector fails twice: the size changes from cloud to cloud, and the same shape listed in another order gives a different vector. As the permutation invariance unit explains, the summary must be permutation invariant.

PointNet, a network published in 2017 by Qi and colleagues, solves this in two steps.

Same MLP for every point, then the maximum of each feature

  1. Shared MLP. One MLP h, with one set of weights, maps each point p on its own to K features. A cloud of n points becomes a table of n rows and K columns. The rows follow the points: shuffle the points and the rows shuffle with them.
  2. Max pooling. For each column k, keep the largest value: gk = max over all points p of hk(p). The table becomes one vector g of K numbers: the summary of the cloud.

The maximum of a list does not depend on the list's order, and the shared MLP treats every point the same way. So g is the same for every order of the points. It holds K numbers, whatever n is. A second MLP then reads g and names the object.

From n points to one summary of K numbers
points same MLP K = 3 features each summary max each column's tallest bar wins
What to notice. Every point goes through the same box h. The summary keeps, for each of the three features, the tallest bar of its column, marked with an outline. Different features can be won by different points.

Worked by hand: four points, three features

Use 2D points to keep the numbers small: A = (0, 0), B = (2, 0), C = (1, 2) and D = (1, 0.5). Let the shared "MLP" be one linear layer followed by ReLU, which keeps positive numbers and turns negative ones into 0. Its three features are

h(x, y) = ( ReLU(x), ReLU(y), ReLU(y − x) )

The third feature says how far a point sits above the diagonal line y = x.

Predict first. Which point will set the largest value of each feature? Will any point not matter at all?

Worked example: the features and their maxima
Pointfeature 1: xfeature 2: yfeature 3: ReLU(y − x)
A = (0, 0)000
B = (2, 0)200 (from −2)
C = (1, 2)121
D = (1, 0.5)10.50 (from −0.5)
max221

The summary is g = (2, 2, 1). B sets feature 1, and C sets features 2 and 3. A and D set no maximum. You could move D a little, or delete it, and the summary would not change.

Shuffling the points cannot change the summary; moving a winner can

The worked example, live: shuffle the list, drag the points
y = x
ListPointxyReLU(y−x)
max

Try it. Predict first: will "Shuffle the list" change the max row? Press it a few times. Then drag point D around. Find a region where D can move without changing the max row, and a move of D that does change it.

Answer

Shuffling only reorders the rows, so the max row never changes. D can move anywhere with x below 2, y below 2 and y − x below 1 without changing the summary, because it never beats B or C. Drag D to the right of x = 2, above y = 2, or more than 1 above the diagonal, and it takes over a maximum. (You can also select a point and move it with the arrow keys.)

What to notice. The highlighted cells are the maxima, and the bottom row is the summary. Only the points that hold a maximum decide the summary.

The maximum keeps the summary steady when points go missing

Any order-free way of combining the rows would work: the sum, the mean or the maximum. The PointNet authors compared max pooling with average pooling and with an attention-weighted sum on a shape classification task, and max pooling won by a large margin. They also showed why it is robust. With K features, at most K points can hold a maximum. They called these the critical points. Deleting any other point, or moving it a little, leaves the summary unchanged, so a cloud with a few missing or noisy points gets nearly the same summary.

Real sizes are larger than the example. The original PointNet used a shared MLP with layer widths 64, 64, 64, 128 and 1,024, so each cloud became a summary of 1,024 numbers. An MLP with widths 512 and 256 then picked the object's class.

pointnet_pool.py

import numpy as np

rng = np.random.default_rng(0)
W1 = rng.normal(size=(3, 64))        # a shared MLP: 3 -> 64 -> 128
W2 = rng.normal(size=(64, 128))

def h(P):                            # P holds one point per row
    return np.maximum(0, P @ W1) @ W2

def pointnet_pool(P):
    return h(P).max(axis=0)          # the largest value of each feature

P = rng.normal(size=(500, 3))        # 500 points in 3D
g = pointnet_pool(P)
print(g.shape)
# Shuffle the points: np.allclose says whether the summary stays the same, up to rounding.
print(np.allclose(g, pointnet_pool(P[rng.permutation(500)])))
print(pointnet_pool(P[:50]).shape)   # 50 points: same size
# argmax(axis=0) finds, for each feature, the point that holds its maximum.
# np.unique keeps each of those points once, and len counts them.
print(len(np.unique(h(P).argmax(axis=0))))  # how many points set a maximum
(128,)
True
(128,)
38

The last line counts the critical points: only 38 of the 500 points decide the 128 numbers of the summary.

What this page leaves out

The full PointNet also learns small "alignment" networks that rotate the input points and the features into a standard pose, and uses batch normalization between layers. A single maximum over the whole cloud also loses detail about local neighborhoods. Its successor, PointNet++, pools over small neighborhoods first, around centers picked by farthest-point sampling, and then pools those results. Attention offers another order-free summary: a learned query can read all the points with cross-attention, giving a weighted average instead of a maximum.

Check yourself

  1. Work a similar problem. The points are (3, 1), (0, 4), (2, 3) and (1, 1), and the shared features are h(x, y) = (x, y, x + y). What is the summary, and which point does not matter?

    Answer

    Feature values: (3, 1, 4), (0, 4, 4), (2, 3, 5) and (1, 1, 2). The maxima are 3, 4 and 5, so the summary is (3, 4, 5). The point (1, 1) holds no maximum, so it does not matter.

  2. A PointNet with K = 1,024 reads one cloud of 500 points and another of 50,000 points. How long is each summary?

    Answer

    1,024 numbers for both. The maximum is taken over the points, so the number of points disappears.

  3. You replace the maximum with the mean. Is the summary still order-free? Which points now affect it?

    Answer

    Yes: a mean does not depend on order either. But now every point affects every number of the summary, so there are no critical points, and a stray noisy point shifts the summary a little.

Go further

Optional background, for readers who want more than this page.

Where this shows up

No unit or explanation builds on this one yet.