Deep learning
Pooling and cheap convolutions
Pooling shrinks the grid by taking a summary of each window. 1x1 and depthwise separable convolutions cut the weights and compute a standard convolution would need.
A CNN needs to shrink its feature maps as it goes deeper. It also needs to keep its cost under control. Pooling handles the shrinking by summarizing each window. 1×1 and depthwise separable convolutions handle the cost by splitting one large operation into smaller ones.
Max pooling
A 2 × 2 max pool takes the largest value in each non-overlapping window. The grid is halved in each direction, and small shifts within a window no longer change the output.
Take a 4 × 4 map and pool it with a 2 × 2 window:
input: output:
1 3 | 2 0 4 2
4 2 | 1 1 2 6
----+----
0 1 | 5 2
2 2 | 3 6Each output is the max of one window: max(1, 3, 4, 2) = 4, max(2, 0, 1, 1) = 2, max(0, 1, 2, 2) = 2 and max(5, 2, 3, 6) = 6.
Average pooling takes the mean instead, which is softer. Modern networks often use strided convolutions for downsampling, but the goal is the same.
Tip
Global average pooling takes the mean of each channel over the whole map. This turns (B, C, H, W) into (B, C), so the classifier head can be a small linear layer. It replaces the large flatten-and-linear head shown on the output shapes page.
1×1 convolutions
A 1 × 1 convolution looks at one position at a time and mixes its channels. It is a cheap, learned channel remix. Bottleneck blocks use it to reduce channels, run a 3 × 3 convolution on the smaller set, then expand again. That lowers the cost of the middle layer.
Depthwise separable convolutions
A standard 3 × 3 convolution mixes space and channels in one step. A depthwise separable convolution splits the work in two:
- A depthwise
3 × 3filter per input channel, which handles space only. - A
1 × 1pointwise convolution, which mixes channels only.
For C_in = C_out = 64 and a 3 × 3 kernel, compare the weight counts:
standard: 64 × 64 × 3 × 3 = 36,864
depthwise separable: 64 × 3 × 3 + 64 × 64 = 4,672That is about 7.9 times fewer weights. MobileNet uses this design for phones and edge devices.
Common mistakes
- Mixing up pool size and stride. A
2 × 2pool with stride 2 halves the grid. With stride 1 it barely shrinks it. - Assuming pooling loses nothing. Pooling discards where a value came from within the window. That is intended for classification, but it hurts tasks that need exact locations, such as detection.
- Using global average pooling for dense outputs. If the task needs a map, not a single vector per image, keep the spatial dimensions.
Check yourself
- What is the output size of
2 × 2max pooling with stride 2 on a6 × 6map?3 × 3. - Why is depthwise separable convolution cheaper? It separates the spatial filter, applied per channel, from the channel mix, a
1 × 1convolution, so it avoids the fullk² · C_in · C_outcost.
Key takeaways
- Pooling shrinks the grid by summarizing windows, typically with a max.
- Global average pooling turns each channel into one number, which keeps the head small.
1 × 1convolutions mix channels cheaply.- Depthwise separable convolutions cut the weights and compute, which matters on small devices.
Further learning
The batch normalization and augmentation details that come with these networks are in the CNN overview.
Related
Convolutional networks
How CNNs use small shared filters, stacked layers and residual connections to learn images, and why transfer learning from pretrained models is the default.
Conv output shapes and parameter counts
Kernel size, stride and padding set the output size of a convolution. Counting weights shows where a CNN keeps its parameters, which is often in the last dense layer.
Transfer learning for vision
Reuse a network trained on a large image dataset and adapt it to your own labels. Early layers carry over, and the head and normalization usually need to change.