liveBook · Manning

GlobalAveragePooling2D

As explained in Deep Learning with Python, Third Edition

A pooling layer that averages each feature map across its spatial dimensions to produce one value per channel.

GlobalAveragePooling2D converts a convolutional feature tensor into a vector by averaging each feature map across its spatial dimensions. A tensor shaped (3, 3, 256) becomes (256,), providing the one-dimensional input expected by Dense layers. section 8.1

From feature maps to classification

A small MNIST ConvNet alternates Conv2D and MaxPooling2D layers, then applies GlobalAveragePooling2D before a ten-unit softmax Dense layer. In a larger dogs-versus-cats model, progressively reduced 7 × 7 feature maps with 512 channels pass through the layer before a single sigmoid unit. section 8.1 section 8.2.3

How Deep Learning with Python, Third Edition covers it

How deep it goes
Explains spatial averaging and resulting shapes, but defers implementation internals and mathematical derivation.
Examples
Uses MNIST digits and dogs-versus-cats models with 3 × 3 or 7 × 7 feature maps before classification.
What it assumes
Assumes familiarity with Conv2D, MaxPooling2D, Dense layers, feature-map shapes, and basic classification outputs.
What you can do after
Build it from scratch in Keras as the transition from a final convolutional block to Dense classification layers.
How it connects
Connects Conv2D, MaxPooling2D, feature maps, Dense layers, and softmax or sigmoid classification.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.