Notes

Global Average Pooling

Global Average Pooling is a clean way to turn a network’s final collection of feature maps into a compact prediction-ready vector. Rather than keeping track of exactly where a feature appeared, it asks how strongly each learned feature is present across the entire input.

How it works

A convolutional layer typically produces an output shaped like channels × height × width. Each channel is a feature map: one may respond to edges, another to a texture, and a later one to a more meaningful pattern. Global Average Pooling (GAP) replaces every height-by-width feature map with its single average value.

  • For each channel, add all spatial activations.
  • Divide by the number of spatial positions.
  • The result is one number per channel.

For example, 512 feature maps of size 7×7 become a vector of 512 values. A final linear layer can then convert that vector into class scores or another desired output.

Why networks use it

GAP removes the large fully connected layers once used at the end of convolutional networks. That sharply reduces parameters, memory use, and the opportunity to overfit. In a ResNet, the final feature tensor is commonly globally averaged before the classifier. Each channel’s average becomes evidence for the feature that channel learned: a high value says that feature appeared strongly and broadly enough to matter.

Unlike local average pooling, GAP covers the entire current spatial extent. It also works with different input sizes, because a 10×10 map and a 20×20 map both collapse to one value per channel.

Trade-offs in practice

GAP deliberately discards precise location. This is useful when the task needs “is this feature present?” but harmful when the output must preserve position, boundaries, or small-object detail. Applying it too early prevents later layers from combining spatial relationships. Used at the end, it provides a strong, simple classification head; used carelessly, it can make distinct arrangements of the same features look identical to the network.

Global Average Pooling reduces each feature map to a single value by averaging all its spatial positions, producing one scalar per channel. Unlike local pooling, it collapses the entire spatial extent and commonly replaces fully connected classification heads. It matters because it greatly reduces parameters, limits overfitting, and makes predictions depend on the presence of learned features rather than their exact locations.

Imagine judging whether a photo contains a dog by asking: “How strongly did the image, as a whole, look dog-like?” You would not need to remember the exact spot where each ear, paw, or patch of fur appeared.

Global Average Pooling gives an image-recognising network that kind of big-picture view. After the network has scanned an image for useful clues, this step takes each type of clue and finds its average strength across the entire image. The detailed map of where things appeared is compressed into a simple summary of whether they appeared. This helps the network make a final classification while keeping it focused on the overall evidence.