Average pooling

Pooling · node type · AveragePool, GlobalAveragePool, ReduceMean

Replaces each window with its mean; global average pooling turns a feature map into one vector.

Also called AvgPool, Global average pooling, GAP, Mean pooling

A 2 × 2 window with stride 2 halves each side. Pick an output cell to see which inputs it summarizes. No weights are learned here.

Global average pool of the whole grid: 2.14

Input 6 × 6

132014521302016231241052302411123126

Output 3 × 3

average(1, 3, 5, 2) = 2.75

Figure 1. Try it: every number is computed in your browser from the formula below.

What it does

Average pooling outputs the mean of each window, per channel. It smooths rather than selects. Its most common form today is global average pooling at the end of a CNN: every channel of the final feature map is averaged into one number, so an image of any size becomes a fixed-length vector that a dense classifier can read. Mean pooling over token positions does the same for sentence embeddings, where ONNX graphs show it as a ReduceMean.

Formula

Y[c, y, x] = (1 / k2) Σi Σj X[c, s·y + i, s·x + j]global: Y[c] = (1 / HW) Σy,x X[c, y, x]

Shapes and parameters

Shapes
Input [N, C, H, W]; output [N, C, H', W'], or [N, C, 1, 1] for global pooling. Over tokens: [N, T, D] to [N, D].
Parameters
None.
Used for
The end of MobileNet, ResNet and SqueezeNet style classifiers, sentence embedding models (mean over tokens), and smoothing inside some detectors.

Figure 2. Average pooling inside Label a photo with ImageNet, a real model in WeightSpace. The outlined node is Average pooling; select any node for its shapes and parameters.

Figure 3. The typed ports of Average pooling, in the same format as every model drawing. Letters such as N or C stand for any size.

In WeightSpace

Read-only in WeightSpace today. In the plant classifier and SqueezeNet it produces the vector that the edited classifier biases are added on top of.