Pooling shrinks a spatial representation by combining values from local neighborhoods. In a convolutional neural network (CNN), it helps keep a small shift in an image from changing the prediction too much. Convolution applies learned filters across locations, but a later fully connected layer can still learn to expect a feature at one particular position. section 3.5 section 3.8
Why a one-pixel shift matters
A CNN gives an MNIST digit's correct class probability as about 0.78 in its original position. Shift the same digit one pixel down and right, and the probability falls to about 0.44; shift it up and left, and it falls to about 0.32. The digit has not changed, but its position has. section 3.5
Max pooling selects the largest value in each local region. With a region size of K, the illustrated output is smaller by a factor of K. In PyTorch, `F.max_pool2d(x, (K, K))` applies this operation to a two-dimensional input; pooling also has a stride setting that controls how far the region moves between selections. Shrinking a representation lets subsequent layers draw context from a larger portion of the original input. section 3.5 section 3.8 section 14.1
The tradeoff is lost information. Direct max pooling can map distinct patterns to identical outputs, an aliasing problem. Pooling a zebra image by a factor of four makes the problem visible in its fine striped detail: selecting one maximum per region does not preserve everything that distinguished neighboring patterns. section 14.1
Figure 14.2 An approach to max pooling that helps mitigate aliasing: also called anti-aliasing. First we do max pooling with a stride of 1 to get an output the same size as the input. Then we apply a blurring kernel/convolution with a stride of 2, which shrinks the output to the desired size and maintains the behavior of max pooling but allows us to delineate that the three outputs came from three different inputs. This approach captures more information than naive max pooling.
Compare the two-stage anti-aliased path with direct max pooling: keep a maximum at every local position, then blur while shrinking. Distinct input patterns can remain distinguishable. section 14.1.2
To reduce aliasing, first max-pool with `stride=1` and padding, retaining an output near the input's size. Then apply a blurring convolution with a larger stride to shrink it. Blurring mixes information from adjacent positions before values are discarded. A center-weighted binomial filter is one blur-kernel choice; the PyTorch implementation packages the blur as a layer that can follow max pooling. section 14.1.2
The aggregation choice also depends on the network's job. In a GAN discriminator, `nn.AvgPool2d` replaces max pooling so every pixel contributes to the result and receives a share of the gradient. An `nn.AdaptiveAvgPool2d(4)` layer near the output reduces dependence on exact feature locations and supplies a fixed 4 × 4 grid per channel to the following linear layer. Strided convolution is another downsampling alternative to compare with pooling. section 9.4.2 section 8.6







