From a representation to class scores AI

How spatial averaging and a linear classifier connect the image maps to predictions.
Published

October 28, 2026

Global average pooling replaces each spatial feature map with its mean. In the image model, 512 maps of 7 × 7 cells become a 512-value vector:

vc=149∑i=17∑j=17acij.v_c=\frac{1}{49}\sum_{i=1}^{7}\sum_{j=1}^{7}a_{cij}.

The spatial grid has been summarized, rather than left empty. The classifier then computes one score per breed:

sk=bk+∑cWkcvc.s_k=b_k+\sum_c W_{kc}v_c.

The coefficients WW and biases bb are learned. A strong channel response does not by itself imply a strong score for every class: the sign and magnitude of that class’s coefficient matter. See PyTorch’s adaptive average pooling and linear layer definitions.

The activity model uses a different summary: its final 128-value recurrent state. It does not average hidden states over time. Both models pass their summary vector to a linear classifier; softmax then converts scores to probabilities. UMAP displays those vectors separately and does not feed the classifier.

Explore the neural-network demo.