Pooling Layers

Pooling layers are used in CNNs to progressively reduce the spatial size of feature maps, which cuts down computation and helps the network focus on the most important patterns rather than exact pixel positions.

Max Pooling

The most common pooling technique - it slides a small window across the feature map and keeps only the maximum value within that window, effectively keeping the strongest signal.

Input (2x2 window): [[1, 3],
                      [2, 4]]
Max Pooling Output: 4

Average Pooling

Instead of taking the maximum, average pooling calculates the mean of all values in the window - it's smoother but can dilute strong, distinctive features compared to max pooling.

Why Pooling Helps

  • Reduces the number of parameters and computation in later layers
  • Helps control overfitting
  • Makes the network more robust to small shifts or distortions in the input (translation invariance)

Implementing in Python

from tensorflow.keras import layers

pool = layers.MaxPooling2D(pool_size=(2,2), strides=2)
While pooling was standard in earlier CNN architectures, some modern networks replace it with strided convolutions instead - both achieve dimensionality reduction, but strided convolutions let the network learn the downsampling pattern rather than using a fixed rule.

Coming Up Next

After several rounds of convolution and pooling, the extracted features need to be combined to make a final prediction - that's the job of the Fully Connected Layers.

Ready to Master Data Science?

Join Uncodemy's Data Science Course and build real, job-ready skills with expert mentors.

Explore Course