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
