liveBook · Manning

Pooling

As explained in Deep Learning with PyTorch, Second Edition

A downsampling technique that reduces spatial resolution by aggregating local regions of a feature map.

Pooling, also called downsampling or subsampling, reduces a feature map’s spatial dimensions by aggregating values from local regions. It lets successive convolutions work with a larger effective scope without using oversized kernels. section 8.2.3

Common ways to compute each lower-resolution value include:

  • Average pooling computes the mean of each region; it was common early on but is less favored. section 8.2.3
  • Max pooling selects the largest value, preserving the strongest response while discarding the other values. section 8.2.3
  • A strided convolution calculates outputs at intervals while still incorporating input from the preceding layer. section 8.2.3

A 2 × 2 max-pooling step

Applying max pooling to non-overlapping 2 × 2 tiles replaces each tile with its largest value. A three-channel 32 × 32 input becomes a three-channel 16 × 16 output. section 8.2.3

# In[21]:
pool = nn.MaxPool2d(2)
output = pool(img.unsqueeze(0))

img.unsqueeze(0).shape, output.shape

# Out[21]:
(torch.Size([1, 3, 32, 32]), torch.Size([1, 3, 16, 16]))

The PyTorch-style example constructs a 2 × 2 max-pooling layer and shows the resulting tensor shapes. section 8.2.3

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Defines regional aggregation, compares three downsampling methods, and focuses on non-overlapping 2 × 2 max-pooling tiles.
Examples
Uses 2 × 2 tiles, a 32 × 32 tensor reduced to 16 × 16, and a MaxPool2d implementation.
What you can do after
Apply it via nn.MaxPool2d to reduce feature-map dimensions between convolutional layers.
How it connects
Connects pooling with convolution, feature maps, downsampling, average pooling, max pooling, and strided convolution.

Also explained in

Compare how 8 books explain pooling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with PyTorch, Second Edition. The section links point to the parts of the book it draws on.