Exercises — Convolution operation and filters
These graded exercises take you from recognizing the convolution formula all the way to building your own layer configurations. Every problem has a full solution hidden inside a collapsible callout — try first, then reveal. This page is the practice companion to Convolution operation and filters.
Prerequisite links you may want open: 2.2.05-Receptive-fields, 3.4.02-Pooling-layers, 3.3.01-Backpropagation, 3.4.03-CNN-architectures.
Level 1 — Recognition
Exercise 1.1 — Read the formula
State, in plain words, what each symbol means in
Recall Solution
- is the input image (a grid of numbers).
- is the filter/kernel, a small grid of weights.
- is the top-left corner of the window we currently sit on.
- index inside the window: they run , so they visit every cell of the filter.
- is the image pixel under filter cell .
- The double sum multiplies each filter weight by the pixel beneath it and adds up all products.
- The result is one number: the template-matching score at that location.
Exercise 1.2 — Output size, plug and chug
An input is , filter , stride , padding . What is the output height ?
Recall Solution
Output is . The image shrank by because we used no padding.
Exercise 1.3 — Name the filter
Which pattern does this filter detect?
Recall Solution
This is a horizontal edge detector. The top row has negative weights, the bottom row positive. It fires strongly (large positive score) when the region below is bright and the region above is dark — i.e. a horizontal boundary from dark-on-top to bright-on-bottom.
Level 2 — Application
Exercise 2.1 — Compute one output cell
Input patch (top-left of some image) and filter:
Compute the convolution score. Look at Figure s01 for the overlay.

Recall Solution
Multiply each cell by the filter cell above it (the middle column is , so ignore it): Score . This filter is a left-minus-right vertical edge detector; the negative value means the right side of this patch is brighter than the left.
Exercise 2.2 — Output size with stride and padding
Input , , stride , padding . Find .
Recall Solution
Output is . Stride 2 roughly halved the size; padding 2 kept the arithmetic clean.
Exercise 2.3 — Full feature map
Input and vertical-edge filter :
Compute the full output. Figure s02 shows the two slide positions.

Recall Solution
Output size: , so . Middle column of is , so we only use left column () and right column (). , window rows 0–2, cols 0–2: , cols 1–3: , rows 1–3, cols 0–2: , rows 1–3, cols 1–3:
Level 3 — Analysis
Exercise 3.1 — Padding to preserve size
You have , stride . What padding keeps the output the same size as the input?
Recall Solution
Set in : . General rule for stride-1 "same" padding: , which needs odd.
Exercise 3.2 — Parameter count
A conv layer takes an input of depth (RGB), uses filters of size , and has one bias per filter. How many learnable parameters?
Recall Solution
Each filter is weights, plus 1 bias per filter. Total parameters. Compare to a fully connected layer on a image feeding 64 outputs: . Convolution's weight sharing is why it wins.
Exercise 3.3 — Receptive field growth
Two stacked conv layers (stride 1, no dilation). What is the receptive field of one output neuron in the second layer, measured on the original input? Connect this to 2.2.05-Receptive-fields.
Recall Solution
One layer sees . Stacking a second on top: each of those positions itself sees , and they overlap. The formula for stacked stride-1 layers: Receptive field . Two cheap layers ( weights) cover the same window as one layer ( weights) — with more nonlinearity and fewer parameters.
Level 4 — Synthesis
Exercise 4.1 — Design a shape-matching stack
You must map a input to a feature map in one conv layer. Give a valid .
Recall Solution
Depth means filters. For the spatial halving , try , : Take : . ✓ So works. (Also valid: .) Depth of each filter is to match the RGB input, giving weights plus 32 biases.
Exercise 4.2 — Multi-channel single output
Input (two channels), filter :
Compute the single output value (valid convolution gives ). See Figure s03.

Recall Solution
Sum over channels, then over the window: Total . The two channel results are added, not stacked — a multi-channel filter collapses all input depth into one number per position.
Level 5 — Mastery
Exercise 5.1 — Dilation and effective kernel
A filter with dilation has gaps inserted between its cells. What is its effective kernel size, and what output size does it give on a input with , ?
Recall Solution
Effective size: . So it covers a region using only weights. Output: , i.e. . Dilation grows the receptive field (2.2.05-Receptive-fields) without adding parameters — the trick behind atrous/dilated convolutions.
Exercise 5.2 — Cost of separable convolution
Compare multiply-adds for one output position (across all channels) between a standard conv with , , and a depthwise-separable version (3.4.10-Depthwise-separable-convolutions).
Recall Solution
Standard: each output channel needs mult-adds; times outputs: Separable = depthwise ( per input channel) + pointwise ( mixing): Ratio : about a 7× reduction in compute for this configuration. That's why mobile CNNs use them.
Exercise 5.3 — Backprop sanity check
In the forward pass an output element is . During 3.3.01-Backpropagation, what is , and what does it tell you about learning?
Recall Solution
The gradient on a filter weight is just the input pixel it multiplied. Summed over every position where the filter fired (because of weight sharing), the update becomes a convolution of the input with the upstream gradient. So the same weight collects evidence from the whole image — this is exactly why a filter learns one consistent feature everywhere. Bright inputs where the filter helped → large positive gradient → weight strengthens.