Exercises — Stride, padding, and dilation
This page is a self-test ladder for the parent topic. Each rung climbs one cognitive level. Try each problem with the callout collapsed, then open the [!recall]- block to grade yourself.
Related tools you may want open: Convolutional Layer Basics, Receptive Field Analysis, Pooling Layers, Semantic Segmentation Architectures, Network Depth vs Width.
Level 1 — Recognition
Goal: read off the right quantity from a definition. No derivation yet.
Exercise 1.1
A kernel is applied with dilation . What is its effective kernel size ?
Recall Solution
Dilation means "insert gaps" — i.e. no gaps at all, an ordinary dense kernel. Answer: . A dilation of 1 is just a normal convolution.
Exercise 1.2
Which hyperparameter changes the number of output pixels without changing how wide an area each filter looks at: stride or dilation?
Recall Solution
Stride. Stride decides how many positions we place the filter — bigger ⇒ fewer positions ⇒ smaller output. Dilation decides how wide a single placement reaches, leaving the count of positions (roughly) unchanged. Answer: stride.
Exercise 1.3
For "same" padding at stride 1 with an odd kernel , what padding keeps output size equal to input size?
Recall Solution
Set in the master formula with , (so ): Answer: . For that is ; for it is .
Reveal-line drill:
Effective kernel of a dilated kernel with
Which parameter is "camera step size"
Level 2 — Application
Goal: plug numbers into the master formula, all cases.
Exercise 2.1
Input , kernel , padding , stride , dilation . Find .
Recall Solution
(since ). Reach (how far the filter's left edge can travel before its right edge leaves the image).
Filter sits at positions — all inside . Answer: .

Exercise 2.2
Input , , , , . Find output size.
Recall Solution
. Padded size . Reach . This is same padding: preserves the shape. Answer: .
Exercise 2.3
Input , , dilation , stride , padding . Find output size.
Recall Solution
First the effective kernel:
Reach .
Answer: . The dilated kernel behaves size-wise like a plain , even though it only holds weights.

Exercise 2.4 (degenerate input)
Input , , , , . What is ?
Recall Solution
Reach , which is negative. A negative "size" is the formula's way of shouting the kernel does not fit — a window cannot sit anywhere inside a image without padding. Answer: no valid output (formula gives ). In practice you must add padding or shrink .
Level 3 — Analysis
Goal: reason about why a value comes out the way it does, compare paths.
Exercise 3.1
You need to halve a feature map to . Using , , choose the stride . Verify.
Recall Solution
Padded size , . Try : Answer: gives exactly . This is the standard "strided conv downsample" — an alternative to a pooling layer that learns its own downsampling.
Exercise 3.2
Two paths both aim for an receptive field. Compare parameter counts.
- Path A: a single kernel.
- Path B: a kernel with dilation .
Recall Solution
Path A parameters: .
Path B effective size: ✓ — same reach.
Path B parameters: .
Answer: A needs weights, B needs — a saving. Dilation buys reach cheaply (see Receptive Field Analysis), at the cost of sparse sampling: B never looks at the pixels sitting in its gaps.

Exercise 3.3
Why does same-padding fail to give an integer for even , and what breaks?
Recall Solution
For : — you cannot add half a pixel of border. The geometric reason: same-padding needs extra pixels split evenly across the two sides. When is odd, is even and splits cleanly ( each side). When is even, is odd and cannot split symmetrically. Fix in practice: pad asymmetrically — e.g. pixel on the left, on the right — which is why odd kernels () dominate CNN design.
Level 4 — Synthesis
Goal: combine all four knobs, chain layers, hit a target.
Exercise 4.1 (all knobs together)
Input , , , , . Find output size.
Recall Solution
Step 1 — effective kernel: . Step 2 — padded input: . Step 3 — reach: . Step 4 — count positions: Answer: . Note the floor mattered here: , and the half-step is a filter that would hang off the edge, so we drop it.
Exercise 4.2 (two-layer chain)
Layer 1: . Layer 2: . Input . Find output after both.
Recall Solution
Layer 1 (same padding): . Still . Layer 2: . Answer: . A same-conv followed by a strided conv — the classic "process then downsample" block seen when trading depth against width.
Exercise 4.3 (design for segmentation)
For dense prediction you must keep the spatial size unchanged while using dilation with , . What padding keeps ?
Recall Solution
. Same-padding condition with : Answer: . General rule: for same padding, pad by , using the effective kernel, not the raw one.
Level 5 — Mastery
Goal: invert the formula, prove a general property, handle limiting behaviour.
Exercise 5.1 (invert for stride)
You must map input to output with , , . Solve for the stride , and confirm the floor cooperates.
Recall Solution
, padded , reach . We need: Solve : try ⇒ ✓. Answer: . Because and the floor knocks it to , then gives exactly . The half-pixel of reach is discarded — the last would-be filter overhangs the edge.
Exercise 5.2 (prove a limiting law)
Show that for a fixed and , , as dilation the output size eventually becomes non-positive for any finite input — i.e. dilation cannot grow forever.
Recall Solution
With : The bracket grows linearly in with slope (for ). So decreases without bound as increases. It hits once Concrete check: for the threshold is . At : , so ✓. Conclusion: the effective kernel outgrows the image, so no filter fits — you must add padding or cap . This is why dilated stacks in practice use increasing then resetting dilation schedules rather than unbounded growth.
Exercise 5.3 (mastery combine + invert)
A layer has , , . You want . Find ; then, keeping that , find if the input were instead .
Recall Solution
Part 1: . Same padding: . Check: ✓. Part 2: same , input : . Answer: ; and with that padding a -input gives out. Same padding is shift-invariant in input size — once is set for a given , it preserves any input size.
Recall Master checklist (reveal after finishing)
Effective kernel formula ::: Output size formula ::: Same padding (general) ::: Negative means ::: kernel does not fit; add padding Floor applies to ::: the division only, and rounds down