A small CNN takes a 32×32×3 image through: (1) a 3×3 conv with 16 filters, stride 1, padding 1; (2) 2×2 max pooling, stride 2; (3) a 3×3 conv with 32 filters, stride 1, padding 1; (4) global average pooling; and (5) a 10-class linear head. Including biases, what are the output shape after each layer and the total parameter count, and why does global average pooling avoid a parameter explosion?

Deep learning, Classic architectures
Level L2 Elementary. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can trace tensor shapes and parameter counts through a multi-layer CNN and compare global average pooling with flattening.

Key idea

Use nout=⌊(n+2p−k)/s⌋+1 for spatial dimensions (where n is input size, p is padding, k is kernel size and s is stride) and (k2Cin+1)Cout for conv parameters (with Cin input and Cout output channels). Global average pooling collapses each H×W feature map to a single number, leaving only Cout features for the linear head.

Steps

  1. Layer 1 (3×3 conv, 16 filters, s=1,p=1): nout=(32+2−3)/1+1=32, so shape is 32×32×16. Parameters: (3×3×3+1)×16=28×16=448.
  2. Layer 2 (2×2 max pool, s=2,p=0): nout=(32−2)/2+1=16, so shape is 16×16×16. Pooling has 0 learnable parameters.
  3. Layer 3 (3×3 conv, 32 filters, s=1,p=1): shape is 16×16×32. Parameters: (3×3×16+1)×32=145×32=4,640.
  4. Layer 4 (global average pooling): averages each of the 32 maps of size 16×16, giving shape 1×1×32 (a 32-D vector) with 0 parameters.
  5. Layer 5 (10-class linear head): output shape is 10, with 32×10+10=330 parameters. Total parameters: 448+4,640+330=5,418.
  6. Comparison with flattening: flattening the 16×16×32 tensor instead would feed 8,192 numbers into the 10-class head, requiring 8,192×10+10=81,930 head parameters (about 248× more in the head alone) and encouraging overfitting.

Common mistakes

How long your answer should be

Half a page; 3–4 minutes.

Last checked on 4 December 2026.

Read this

Previous in Deep learning: An activation tensor of shape 28×28×192 passes through a 1×1 convolutional layer with 64 filters (including biases). What are the output shape, the number of learnable parameters and the multiply-accumulate (MAC) count, and why do architectures such as Inception and ResNet use 1×1 convolutions?
Next in Deep learning: What single key architectural change did each of AlexNet, VGG, Inception, ResNet and DenseNet introduce over prior CNNs?