Downsampling
Pooling and strided convolutions: reducing spatial dimensions to grow the receptive field efficiently.
The previous article showed how a convolutional filter produces a feature map of the same spatial size as the input (with same padding). After a stack of such layers, the network holds large feature maps at every stage — computationally expensive to process and, more importantly, not well-suited for recognizing the large-scale patterns that distinguish one class from another. A 3×3 filter sees only a 3×3 neighbourhood; if the spatial resolution never decreases, many layers are needed before any single unit "sees" a wide enough region of the image to detect, say, the outline of an animal. Downsampling solves both problems by deliberately reducing spatial resolution at key points in the network.
The Receptive Field Problem
A 3×3 convolution with stride 1 has a receptive field of 3×3: each output cell integrates information from a 3×3 patch of its input. Stack five such layers and the receptive field grows to pixels — still far less than the pixels wide a typical image. To see the whole image, you would need over 100 layers of stride-1 convolutions.
Downsampling multiplies the receptive field growth rate of every subsequent layer. A 3×3 convolution applied to a feature map at half the original resolution "sees" twice as many original pixels per step. Three stages of downsampling mean a convolution at the deepest level covers original pixels per dimension. Four stages cover pixels — enough to see a large portion of a 224-pixel image in a single operation.
Max Pooling
Max pooling is the most common spatial downsampling operation. A pooling window of size slides over the feature map with stride , and at each position the output is the maximum value within the window:
The standard choice is a window with stride , which halves both height and width. The four quadrants of a feature map each contribute one value to a output:
Max pooling has no trainable parameters. It acts as a feature selector: within each window, only the strongest activation survives. This provides a limited form of translation invariance — a feature shifted by one pixel within a pooling window produces the same output.
Backpropagation through max pooling. During the forward pass, the position of the maximum within each window is recorded. During the backward pass, the upstream gradient flows exclusively to the max position; all other positions in the window receive a gradient of zero. This is sometimes called a "winner-takes-all" backward pass.
Average Pooling
Average pooling replaces the maximum with the mean of the window:
For the same input, a average pool with stride produces:
Average pooling distributes the gradient evenly across all cells in the window during backpropagation. It is smoother than max pooling but often performs slightly worse for image classification, where the presence of a feature matters more than its average strength.
Global average pooling (GAP) is a special case where the window covers the entire feature map. A feature map passed through global average pooling becomes a -dimensional vector — one value per channel, representing the mean activation of that filter across the entire spatial extent. GAP is widely used as the bridge between the convolutional body of a network and the final classification layer, replacing large fully connected layers that would otherwise require millions of parameters.
Strided Convolutions
An alternative to pooling is to perform downsampling inside the convolution itself by increasing the stride. With stride , the filter moves pixels at each step rather than one:
A convolution with stride and padding on a input produces:
Compared to max pooling, strided convolutions have two differences:
- Learnable. The filter weights are trained, so the network can learn which information to preserve when downsampling, rather than blindly taking the maximum.
- No explicit pooling step. Downsampling and feature extraction happen simultaneously, which some architectures find preferable.
Modern architectures such as ResNet use strided convolutions for downsampling rather than separate pooling layers. Older architectures (VGG, AlexNet) used separate max pool layers. Both approaches are effective; the choice is largely a design convention.
Receptive Field Growth in Practice
A typical convolutional network for images processes the input through four downsampling stages, each reducing spatial dimensions by :
| Stage | Spatial size | Downsampling factor | 3×3 conv covers |
|---|---|---|---|
| 1 | 112 × 112 | 2× | 6 original px |
| 2 | 56 × 56 | 4× | 12 original px |
| 3 | 28 × 28 | 8× | 24 original px |
| 4 | 14 × 14 | 16× | 48 original px |
By the final stage, even a single convolution integrates information from a region of the original image. Multiple such convolutions within a stage, combined with the accumulated depth from earlier layers, give the network effectively global spatial awareness before the classifier is applied.
Putting It Together
A standard convolutional body alternates between convolutional layers (that maintain resolution and increase channel depth) and downsampling operations (that halve resolution). This pattern appears in virtually every image classification network:
input (3 × H × W)
→ conv stage 1 → downsample → (C₁ × H/2 × W/2)
→ conv stage 2 → downsample → (C₂ × H/4 × W/4)
→ conv stage 3 → downsample → (C₃ × H/8 × W/8)
→ global average pool → (C₃,)
→ linear classifier → (num_classes,)
Channel depth grows at each stage (32 → 64 → 128 is typical), compensating for the reduced spatial size. The total number of activations stays roughly constant, keeping per-layer compute balanced.
In Code
import torch
import torch.nn as nn
x = torch.tensor([[[[1., 3., 2., 4.],
[5., 6., 7., 8.],
[3., 2., 1., 6.],
[4., 1., 5., 3.]]]]) # shape: (1, 1, 4, 4)
# Max pooling: keeps the strongest activation of each 2×2 window; halves H and W
max_pool = nn.MaxPool2d(kernel_size=2, stride=2)
print(max_pool(x))
# tensor([[[[6., 8.],
# [4., 6.]]]])
# Average pooling: keeps the mean of each window instead
avg_pool = nn.AvgPool2d(kernel_size=2, stride=2)
print(avg_pool(x))
# tensor([[[[3.7500, 5.2500],
# [2.5000, 3.7500]]]])
# Strided convolution: downsampling fused into the convolution.
# One strided conv replaces a conv + pool pair, and its kernel learns what to preserve.
conv_stride2 = nn.Conv2d(in_channels=1, out_channels=1,
kernel_size=3, stride=2, padding=1)
# (4 + 2×1 − 3) / 2 + 1 = 2 → output shape (1, 1, 2, 2)
print(conv_stride2(x).shape) # torch.Size([1, 1, 2, 2])
# Global average pooling: collapses each feature map to one number, (1, 512, 7, 7) → (1, 512)
gap = nn.AdaptiveAvgPool2d(1)
feature_maps = torch.randn(1, 512, 7, 7)
out = gap(feature_maps).flatten(1)
print(out.shape) # torch.Size([1, 512])
Downsampling controls the trade-off between spatial resolution and the breadth of patterns a network can see. With the convolution operation and downsampling in place, the remaining question is computational: naively applying a filter to every patch is slow. The next article shows how the im2col transformation converts convolution into a single dense matrix multiplication, unlocking the full throughput of modern hardware.