Diving into the Pool: Unraveling the Magic of CNN Pooling Layers – KDnuggets #Imaginations Hub

Diving into the Pool: Unraveling the Magic of CNN Pooling Layers – KDnuggets #Imaginations Hub
Image source - Pexels.com



Pooling layers are widespread in CNN architectures utilized in all state-of-the-art deep studying fashions. They’re prevalent in Pc Imaginative and prescient duties together with Classification, Segmentation, Object Detection, Autoencoders and lots of extra; merely used wherever we discover Convolutional layers.

On this article, we’ll dig into the mathematics that makes pooling layers work and be taught when to make use of differing types. We’ll additionally work out what makes every sort particular and the way they’re totally different from each other.



Pooling layers present numerous advantages making them a typical alternative for CNN architectures. They play a vital position in managing spatial dimensions and allow fashions to be taught totally different options from the dataset.

Listed here are some advantages of utilizing pooling layers in your fashions:

All pooling operations choose a subsample of values from an entire convolutional output grid. This downsamples the outputs leading to a lower in parameters and computation for subsequent layers, which is a crucial good thing about Convolutional architectures over absolutely related fashions.

Pooling layers make machine studying fashions invariant to small adjustments in enter resembling rotations, translations or augmentations. This makes the mannequin appropriate for primary pc imaginative and prescient duties permitting it to establish comparable picture patterns.  

Now, allow us to have a look at numerous pooling strategies generally utilized in apply.



For ease of comparability let’s use a easy 2-dimensional matrix and apply totally different strategies with the identical parameters.

Pooling layers inherit the identical terminology because the Convolutional Layers, and the idea of Kernel Dimension, Stride and Padding is conserved.

So, right here we outline a 2-D matrix with 4 rows and 4 columns. To make use of Pooling, we’ll use a Kernel dimension of two and stride two with no padding. Our matrix will look as follows.


Picture by Writer


You will need to notice that pooling is utilized on a per-channel foundation. So the identical pooling operations are repeated for every channel in a function map. The variety of channels stays invariant, despite the fact that the enter function map is downsampled.



We iterate the kernel over the matrix and choose the max worth from every window. Within the above instance, we use a 2×2 kernel with stride two and iterate over the matrix forming 4 totally different home windows, denoted by totally different colors.

In Max Pooling, we solely retain the most important worth from every window. This downsamples the matrix, and we get hold of a smaller 2×2 grid as our max pooling output.


Diving into the Pool: Unraveling the Magic of CNN Pooling Layers
Picture by Writer


Advantages of Max Pooling


  • Protect Excessive Activation Values

When utilized to activation outputs of a convolutional layer, we’re successfully solely capturing the upper activation values. It’s helpful in duties the place larger activations are important, resembling object detection. Successfully we’re downsampling our matrix, however we will nonetheless protect the vital data in our knowledge.

Most values usually signify the necessary options in our knowledge. Once we retain such values, we preserve data the mannequin considers necessary. 

As we base our determination on a single worth in a window, small variations in different values could be ignored, making it extra sturdy to noise.




  • Doable Lack of Info

Basing our determination on the maximal worth ignores the opposite activation values within the window. Discarding such data may end up in potential lack of useful data, irrecoverable in subsequent layers.

  • Insensitive to Small Shifts

In Max Pooling, small adjustments within the non-maximal values will likely be ignored. This insensitivity to small adjustments could be problematic and may bias the outcomes.

Regardless that small variations in values will likely be ignored, excessive noise or error in a single activation worth may end up in the collection of an outlier. This will alter the max pooling consequence considerably, inflicting degradation of outcomes.



In common pooling, we equally iterate over home windows. Nonetheless, we contemplate all values within the window, take the imply after which output that as our consequence.


Diving into the Pool: Unraveling the Magic of CNN Pooling Layers
Picture by Writer


Advantages of Common Pooling


  • Preserving Spatial Info

In principle, we’re retaining some data from all values within the window, to seize the central tendency of the activation values. In impact, we lose much less data and may persist extra spatial data from the convolutional activation values.

Averaging all values makes this technique extra sturdy to outliers relative to Max Pooling, as a single excessive worth can’t considerably alter the outcomes of the pooling layer.

When taking the imply of values, we get hold of much less sharp transitions between our outputs. This supplies a generalized illustration of our knowledge, permitting lowered distinction between subsequent layers.




  • Incapacity to Seize Salient Options

All values in a window are handled equally when the Common Pooling layer is utilized. This fails to seize the dominant options from a convolutional layer, which could be problematic for some drawback domains.

  • Lowered Discrimination Between Options Maps

When all values are averaged, we will solely seize the widespread options between areas. As such, we will lose the distinctions between sure options and patterns in a picture, which is definitely an issue for duties resembling Object Detection.



World Pooling is totally different from regular pooling layers. It has no idea of home windows, kernel dimension or stride. We contemplate the entire matrix as a complete and contemplate all values within the grid. Within the context of the above instance, we take the typical of all values within the 4×4 matrix and get a singular worth as our consequence.


Diving into the Pool: Unraveling the Magic of CNN Pooling Layers – KDnuggets #Imaginations Hub
Picture by Writer


When to Use


World Common Pooling permits for simple and sturdy CNN architectures. With the usage of World Pooling, we will implement generalizable fashions, which are relevant to enter pictures of any dimension. World Pooling layers are instantly used earlier than dense layers.

The convolutional layers downsample every picture, relying on kernel iterations and strides. Nonetheless, the identical convolutions utilized to pictures of various sizes will end in an output of various shapes. All pictures are downsampled by the identical ratio, so bigger pictures can have bigger output shapes. This generally is a drawback when passing it to Dense layers for classification, as dimension mismatch may cause runtime exceptions.

With out modifications in hyperparameters or mannequin structure, implementing a mannequin relevant to all picture shapes could be tough. This drawback is mitigated utilizing World Common Pooling.

When World Pooling is utilized earlier than Dense layers, all enter sizes will likely be lowered to a dimension of 1×1. So an enter of both (5,5) or (50,50) will likely be downsampled to dimension 1×1. They’ll then be flattened and despatched to the Dense layers with out worrying about dimension mismatches.



We lined some elementary pooling strategies and the eventualities the place every is relevant. It’s vital to decide on the one appropriate for our particular duties.

It’s important to make clear that there aren’t any learnable parameters in pooling layers. They’re merely sliding home windows performing primary mathematical operations. Pooling layers are usually not trainable, but they supercharge CNN architectures permitting sooner computation and robustness in studying enter options.
Muhammad Arham is a Deep Studying Engineer working in Pc Imaginative and prescient and Pure Language Processing. He has labored on the deployment and optimizations of a number of generative AI functions that reached the worldwide prime charts at Vyro.AI. He’s concerned about constructing and optimizing machine studying fashions for clever methods and believes in continuous enchancment.

Related articles

You may also be interested in