RECEPTIVE FIELD

Ch 6 ▸ Receptive fields ▸ Module 2/4

  1. 1One layer
  2. 2Stacking layers
  3. 3Stride and pooling
  4. 4Not every pixel counts

Stacking layers.

🔒 This module is locked

It builds on One layer. Pass that module’s knowledge check to unlock it, or skip ahead if you already know the material.

Go to One layer

Put a second 3×3 convolution on top of the first. A unit of layer 2 reads a 3×3 patch of layer 1’s map, and each of those nine units reads its own 3×3 patch of the image. The layer-2 unit’s field is everything those nine units can see.

Follow one row. The layer-2 unit at column 16 reads layer-1 units 15, 16 and 17:

Together they cover pixels 14 to 18, five pixels. The same happens down the columns, so the field is 5×5 and r=5r = 5.

FIG 6.2 ▸ RECEPTIVE FIELD 32×32 → 32×32 · 2 LAYERS

From aboveDrag to turn the stack. Click any square to trace it.

From the sideThe row inside the dashed sheet. Point at any unit.

▸ L2 UNIT (15, 15) · r = 5 · JUMP 1 · SEES 5×5 = 25 INPUT PIXELS

model = nn.Sequential(OUTrJUMP
32×3211
nn.Conv2d(1, 1, 3, padding=1), 32×3231
nn.Conv2d(1, 1, 3, padding=1), 32×3251
)
Add
Reset
The blue square is the unit being traced. Amber marks every unit and pixel it depends on, down to the input, and the dashed square on the input is the field size r from the formula. Pick a different unit in either view, or a layer in the listing. Arrow keys move the blue square.

Figure 6.2 starts with these two layers. In the view from the side, the lines from the blue unit fan out to three units of layer 1, and from those to five pixels of the input.

Each layer adds the same amount

Add a third layer, and the field grows to 7. Add a fourth, and it grows to 9. Each 3×3 layer at stride 1 adds 2, one pixel on each side. The outermost units it reads sit one pixel left and one pixel right of center, and each brings its own field with it.

In general, a layer with kernel size kk at stride 1 adds k−1k - 1. A stack of LL such layers has

r=1+L (k−1)r = 1 + L\,(k - 1)

For 3×3 kernels that’s 2L+12L + 1: 10 layers give r=21r = 21. With dilation, use the effective size d(k−1)+1d(k-1)+1 in place of kk.

Keep adding layers. After 16 layers the field size is 33, larger than the 32-pixel image. On the input, the dashed square now hangs past the edge of the duck, and the part that hangs over is padding.

Small kernels, stacked

Two 3×3 layers see a 5×5 field, the same as one 5×5 layer. Three 3×3 layers see 7×7, the same as one 7×7 layer. The stacks use fewer weights:

FieldOne big kernelStacked 3×3 kernels
5×525 weights2 × 9 = 18 weights
7×749 weights3 × 9 = 27 weights

The two aren’t the same function, since a stack computes three dot products in a row instead of one. But they read the same pixels with fewer weights. VGG, a 2014 network, is built almost entirely from 3×3 convolutions for this reason.

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. 1Three 3×3 convolutions at stride 1, one after another. What is r for a unit of the third layer?

  2. 2Two 5×5 convolutions at stride 1. What is r for a unit of the second layer?

  3. 3Three 3×3 convolutions with one channel each. How many weights do they have in total?

  4. 4Why does each 3×3 layer at stride 1 add exactly 2 to r?

0 of 4 answered correctly.

🔒 Next module: Stride and pooling