A ConvNet needs to shrink its feature maps as it builds larger-scale visual patterns. Max pooling does this by taking the largest value in each local window, separately for each channel. Unlike a convolution, it uses a fixed maximum operation rather than a learned kernel. section 8.1.2
A first pooling layer
For MNIST digits, a Conv2D layer produces a 26 × 26 × 64 feature map. MaxPooling2D(pool_size=2) reduces it to 13 × 13 × 64: height and width halve, while the channel count stays at 64. A typical choice is a 2 × 2 window with stride 2. section 8.1 section 8.1.2
Listing 8.1 Instantiating a small ConvNet
import keras from keras import layers inputs = keras.Input(shape=(28, 28, 1)) x = layers.Conv2D(filters=64, kernel_size=3, activation="relu")(inputs) x = layers.MaxPooling2D(pool_size=2)(x) x = layers.Conv2D(filters=128, kernel_size=3, activation="relu")(x) x = layers.MaxPooling2D(pool_size=2)(x) x = layers.Conv2D(filters=256, kernel_size=3, activation="relu")(x) x = layers.GlobalAveragePooling2D()(x) outputs = layers.Dense(10, activation="softmax")(x) model = keras.Model(inputs=inputs, outputs=outputs)
See how two MaxPooling2D layers are placed between Conv2D layers before global average pooling and classification. section 8.1
Why keep the downsampling stages?
- Later convolution layers can draw on a greater spatial extent of the original image, supporting a hierarchy of features. section 8.1.2 section 20.1.6
- Feature maps remain manageable as channel counts grow. Without pooling, the MNIST example ends with a 22 × 22 map rather than a 3 × 3 map before global averaging, which can discard much more spatial information. section 8.1.2 section 20.1.6
For larger images, add pooling stages as needed: a 180 × 180 dogs-versus-cats classifier alternates Conv2D and MaxPooling2D until its maps reach 7 × 7 before global average pooling. Check the model summary as you build; spatial dimensions should decrease while feature depth can increase. section 8.2.3









