A convolutional layer takes a 32×32×3 input and applies 16 filters of size 5×5 with stride 1 and padding 2. What is the output shape, and how many learnable parameters does the layer have? What changes if the stride is 2 and the padding is 0?

Deep learning, Convolutional networks
Level L2 Elementary. Length Short. Nature Mat Mathematical.

What's being asked

Whether you know the output-size formula, and that each filter spans the full input depth.

Key idea

For input width W, kernel size K, padding P and stride S, the output width is O=⌊W−K+2PS⌋+1, where ⌊⋅⌋ rounds down. The parameter count is (K⋅K⋅Cin+1)⋅Cout, for Cin input channels and Cout filters. It does not depend on stride, padding or input width.

Steps

  1. Output size: O=32−5+2⋅21+1=32. So the output is 32×32×16, because the depth equals the number of filters.
  2. Parameters: each filter has 5×5×3=75 weights plus 1 bias, so (75+1)×16=1216.
  3. Stride 2, padding 0: O=⌊32−52⌋+1=13+1=14, so the output is 14×14×16. There are still 1216 parameters.
  4. Optional contrast: a fully connected layer from 32⋅32⋅3=3072 inputs to 32⋅32⋅16=16384 outputs needs 3072×16384≈5.0×107 weights. Convolutions are cheap because of weight sharing: the same filter is reused at every position.

Common mistakes

How long your answer should be

4–5 lines of arithmetic; under 2 minutes.

Last checked on 4 December 2026.

Read this

Previous in Deep learning: Let f(x,y)=ax2log⁡(by+c), where the inputs x,y and the parameters a,b,c are all scalars and log⁡ is the natural log. What is the computational graph with intermediate nodes, and how do you use backpropagation on it to compute ∂f/∂b?
Next in Deep learning: What is the receptive field of a unit after three stacked 3×3 convolutions with stride 1, and how does their total parameter count compare with a single 7×7 convolution (both with C input and C output channels, ignoring biases)?