In a typical CNN image classifier, the convolutional and pooling layers output a stack of 2D feature maps, but the final classification layers are fully connected and expect a 1D input vector. What layer bridges this gap?
Select an answer to reveal the explanation.
Short Explanation
Think of it like unrolling a stack of grids into one long line of numbers. After convolution and pooling, you've got a bunch of 2D (or technically 3D, with channels) feature maps, but a fully connected layer only knows how to take a flat list of numbers as input. The flattening layer's whole job is that reshape — take every value across every feature map and lay them out end to end into one 1D vector, with no math involved, just a reorganization of the same numbers. Pooling downsamples spatial dimensions but doesn't flatten anything. Batch norm just rescales values in place — same shape in, same shape out. And softmax comes way later, turning final scores into probabilities, not reshaping feature maps.
Full Explanation
The flattening layer's job is purely structural: it takes the multi-dimensional output of the final convolutional/pooling block — typically shaped as (height, width, channels) — and reshapes it into a single 1D vector, with no learnable parameters and no change to the underlying values, only their arrangement. This 1D vector is what a fully connected (dense) layer requires as input, since dense layers connect every input value to every neuron via a weight matrix that assumes a flat vector shape. Without flattening, you cannot feed spatial feature maps directly into a dense layer's matrix multiplication.
The first distractor, pooling, is a legitimate CNN operation but serves a different purpose: it downsamples the spatial dimensions of feature maps (e.g., via max or average pooling) to reduce computation and add a degree of translation invariance — it does not reshape data into a 1D vector, and pooled output is still multi-dimensional. The third distractor, batch normalization, rescales activation values to have a stable distribution (zero mean, unit variance, with learned scale/shift) but preserves the original tensor shape entirely; it never converts a 2D/3D feature map into 1D. The fourth distractor, softmax, operates at the very end of the network on the final layer's raw output scores (logits), converting them into a probability distribution over classes — it has nothing to do with reshaping intermediate feature maps and typically operates on an already-1D vector of class scores.
Memory aid: picture peeling every 'slice' of a feature-map stack and laying the slices end-to-end into a single long ribbon of numbers — that ribbon is exactly what the dense classification head consumes.