Press ESC to exit fullscreen
πŸ“– Lesson ⏱️ 60 minutes

Pooling Layers

Using pooling layers to reduce dimensionality

Introduction

Pooling layers are essential components in Convolutional Neural Networks (CNNs) that help reduce the spatial dimensions of feature maps, making models efficient and reducing overfitting.


1️⃣ What are Pooling Layers?

Pooling layers:

βœ… Downsample the spatial size of feature maps.
βœ… Retain important features while reducing computational load.
βœ… Help achieve spatial invariance by reducing sensitivity to small translations in the input.


2️⃣ Why are Pooling Layers Important?

βœ… Reduce the number of parameters and computation in the network.
βœ… Control overfitting by reducing feature map size.
βœ… Preserve important information while discarding unnecessary details.


3️⃣ Types of Pooling

Max Pooling

Takes the maximum value from each region of the feature map.

Example: For a 2x2 region:

[1, 3]
[2, 4] -> Output: 4

Max pooling helps capture the most prominent features in a region.


Average Pooling

Takes the average value from each region of the feature map.

Example: For a 2x2 region:

[1, 3]
[2, 4] -> Output: (1+3+2+4)/4 = 2.5

Average pooling smooths out feature maps and retains average context.


4️⃣ Pooling Parameters

βœ… Pool Size: The size of the region to pool (e.g., 2x2).
βœ… Stride: Determines how much the window moves each step (often equal to pool size).


5️⃣ Example in TensorFlow

import tensorflow as tf

model = tf.keras.Sequential([
    tf.keras.layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)),
    tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=2),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(10, activation='softmax')
])

6️⃣ When to Use Pooling Layers

βœ… After convolutional layers to reduce spatial dimensions.
βœ… Before flattening layers to prepare for fully connected layers in CNNs.
βœ… Use max pooling for most image tasks; average pooling may be used for feature smoothing.


Conclusion

βœ… Pooling layers are vital for downsampling and extracting dominant features in CNNs.
βœ… Max pooling and average pooling are the most common types, helping models generalize better while reducing computation.


What’s Next?

βœ… Experiment with different pool sizes and observe how feature map dimensions change.
βœ… Visualize feature maps before and after pooling for better intuition.
βœ… Continue your structured deep learning learning on superml.org.


Join the SuperML Community to discuss your CNN designs and get feedback.


Happy Learning! πŸ“Š