XenonStack Glossary: AI, Data and Cloud Terms Explained

What Is Average Pooling in CNNs? Explained

Written by Dr. Jagreet Kaur | 17 Mar 2023

Average pooling is a downsampling operation in convolutional neural networks that replaces each window of a feature map with the average of its values. It has no learnable parameters and it shrinks the height and width of the input while keeping the channels.

This page is for data scientists and engineers building or reviewing CNNs. It covers what average pooling is, how it works, how it differs from max pooling and what global average pooling adds.

What is average pooling?

In Keras documentation, the AveragePooling2D layer is described as downsampling the input along its spatial dimensions (height and width) by taking the average value over an input window for each channel of the input. The window is shifted by the stride along each dimension.

The Dive into Deep Learning textbook adds that pooling layers have no kernel or learnable parameters, so they are deterministic. Average pooling outputs the mean of each window, while max pooling outputs the largest value.

Why do CNNs use pooling?

According to Dive into Deep Learning, pooling helps mitigate the sensitivity of convolutional layers to location and spatially downsamples the representation. Reducing resolution also lets each hidden unit's receptive field grow faster with depth.

Pooling works on each channel separately, so the output has the same number of channels as the input.

How does average pooling work?

Take a window, such as 2 by 2, and slide it across the feature map. At each position, output the mean of the values inside. Three settings control the result.

  • Pool size: the width and height of the window.
  • Stride: how far the window moves each step. In Keras it defaults to the pool size, so windows do not overlap.
  • Padding: "valid" means no padding. "same" pads evenly so the output has the same height and width as the input.

For a worked case, a 3 by 4 input with a 2 by 2 window and stride 2 under valid padding gives a 1 by 2 output. The Keras page shows this example, and its values are 3.5 and 5.5.

What is the difference between average pooling and max pooling?

QuestionAverage poolingMax pooling
What does it output?The mean of each windowThe largest value in each window
What does it keep?A smoothed summary of the whole windowThe strongest activation in the window
Learnable parameters?NoneNone
Current preferenceUsed mainly in older CNN architectures and in global form near the outputDive into Deep Learning calls it preferable in almost all cases

The choice is empirical. Try both on your own data and compare validation results.

What is global average pooling?

Global average pooling takes the average over a whole feature map, giving one value per channel. The Network In Network paper proposed using it in the classification layer in place of fully connected layers, and its abstract says this is easier to interpret and less prone to overfitting than traditional fully connected layers.

How does average pooling relate to AI agents?

Pooling sits inside the perception models that agents may call, such as image classifiers used in inspection or document workflows. The agent does not see the pooling layer, but its choice affects how the model summarises an image. Teams assembling agents with vision models can read about ElixirClaw, the AI agents computing platform from XenonStack.

What should you do first?

  1. Start with max pooling in a new CNN, then test average pooling as a variant.
  2. Set pool size and stride deliberately, and check the output shape.
  3. Consider global average pooling before the classifier head.
  4. Compare validation accuracy, not only training accuracy.
  5. Record the settings with the model so results can be reproduced.

To map one decision your agents make, and the data and policy it depends on, book a Context Workshop. See what happens in the workshop.

Frequently asked questions

What is average pooling?

Average pooling downsamples a feature map by taking the average value over each window of the input, separately for each channel.

Does average pooling have learnable parameters?

No. Pooling layers have no kernel or learnable parameters, so they are deterministic.

Is average pooling better than max pooling?

Not generally. Dive into Deep Learning calls max pooling preferable to average pooling in almost all cases, but you should compare both on your own data.

What is global average pooling?

Global average pooling averages each whole feature map into a single value per channel. The Network In Network paper proposed it as a replacement for fully connected classification layers.

Why use pooling at all?

Pooling reduces the sensitivity of convolutional layers to location and downsamples the representation, which also lets receptive fields grow faster with depth.