RECEPTIVE FIELD

Ch 3 ▸ Stride, padding and dilation ▸ Module 3/4

  1. 1Stride
  2. 2Padding
  3. 3Dilation
  4. 4Putting it together

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.

Go to Padding

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.

FIG 3.3 ▸ DILATION3×3 KERNEL ON A 7×7 PATCH

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

The same 3×3 kernel at three dilations. The filled squares are the nine pixels it multiplies by its nine weights. The outline is the area those pixels span. More dilation covers more of the image with the same nine weights.

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.

FIG 3.4A ▸ INPUT x18×18
The input x, 16×16, padded to 18×18. The highlighted squares are the nine pixels the kernel reads.
FIG 3.4B ▸ OUTPUT y16×16
DARKBRIGHT
The output map y, 16×16, written one dot product at a time. Every weight is positive, so the output is shaded like the input: brighter means a larger value.
0/0 OUTPUTS · SWEEP 0.0 S
Dilation

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:

keff=d (k−1)+1k_{\text{eff}} = d\,(k - 1) + 1

For k=3k = 3 and d=2d = 2 that’s 5. For sizing purposes, a dilated kernel behaves exactly like a solid kernel of size keffk_\text{eff}, 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.

  1. 1How many weights does a 3×3 kernel have at dilation 2?

  2. 2What does dilation change?

  3. 3A 3×3 kernel at dilation 3 spans an area how many pixels wide?

  4. 4A 3×3 kernel at dilation 2 on a 32×32 input, stride 1. What padding keeps the output 32×32?

0 of 4 answered correctly.

🔒 Next module: Putting it together