Ch 3 ▸ Stride, padding and dilation ▸ Module 3/4
Dilation.
🔒 This module is locked
It builds on Padding. Pass that module’s knowledge check to unlock it, or skip ahead if you already know the material.
A 3×3 kernel has nine weights. Normally they line up with nine neighboring pixels, a solid 3×3 block, and each output is those nine pixels times those nine weights, added up.
Dilation keeps the same nine weights but spreads out which pixels they line up with. At dilation 2 the kernel reads every second pixel, so there’s a one-pixel gap between its taps. At dilation 3 the gap is two pixels.
dilation 1reads 9 pixels across 3×3
dilation 2reads 9 pixels across 5×5, skipping 1 between taps
dilation 3reads 9 pixels across 7×7, skipping 2 between taps
Think of the kernel as a net with nine knots. Dilation stretches the net: it covers a bigger area, but it still has only nine knots, and the pixels that fall between knots are skipped completely. Everything else about the computation is the same. Each output is still nine weights times nine pixels, added up. Only which nine pixels changes.
Now watch it move. Switch to dilation 2 and look at figure 3.4a: the nine highlighted squares spread apart, with gaps between them.
Because the stretched kernel covers 5×5 instead of 3×3, it fits in fewer positions, and the output shrinks from 16×16 to 14×14. The area a dilated kernel covers is its effective size:
For and that’s 5. For sizing purposes, a dilated kernel behaves exactly like a solid kernel of size , so keeping the output at 16×16 would take padding 2 instead of 1.
Why bother? Each output gets to see a wider area of the image for the same nine weights and the same amount of arithmetic. Stack a few dilated layers and each output depends on a large region of the image while the map stays at full resolution. Segmentation models such as DeepLab rely on this. Chapter 6, on receptive fields, follows that idea further.
Knowledge check ▸ 4 questions
Before you move on.
Answer every question correctly to unlock the next module. A wrong answer gets a hint, and you can try again as many times as you like.
1How many weights does a 3×3 kernel have at dilation 2?
2What does dilation change?
3A 3×3 kernel at dilation 3 spans an area how many pixels wide?
4A 3×3 kernel at dilation 2 on a 32×32 input, stride 1. What padding keeps the output 32×32?