Quiz: convolutional networks

Short questions on convolutional layers, pooling, receptive fields and augmentation. Try each on paper first, then open the answer. A convolutional layer with C_\text{out} kernels of size k \times k on C_\text{in} channels has k^2C_\text{in}C_\text{out} + C_\text{out} weights; output size \lfloor(n + 2p - k)/s\rfloor + 1.


Q1. A convolutional layer has 32 kernels of size 3 \times 3 on an RGB image. How many weights does it have? How many for a 256 \times 256 image, and for a 2048 \times 2048 image?

Each kernel covers all 3 channels.

3 \cdot 3 \cdot 3 \cdot 32 + 32 = 896, for both image sizes: the same kernels are used at every position.


Q2. The input is shifted 5 pixels to the right. What happens to the feature maps of a convolutional layer (stride 1)?

Equivariance.

They shift 5 pixels to the right as well (apart from the border columns): the same kernel sees the same neighbourhoods, now 5 pixels further right.


Q3. A 64 \times 64 feature map goes through 2×2 max pooling, then a 3 \times 3 convolution with stride 2 and padding 1. What is the final size?

\lfloor(n + 2p - k)/s\rfloor + 1, twice.

Pooling: \lfloor(64 - 2)/2\rfloor + 1 = 32. Convolution: \lfloor(32 + 2 - 3)/2\rfloor + 1 = 16. So 16 \times 16.


Q4. What is the receptive field of four stacked 3 \times 3 convolutions (stride 1, no pooling)?

Each layer adds 2.

1 + 4 \cdot 2 = 9 pixels: a 9 \times 9 patch.


Q5. Why are the layer-1 kernels of a trained network worth looking at as pictures, but the layer-3 kernels hardly?

What does each kernel act on?

Layer-1 kernels act on pixels, so a kernel’s picture is the image pattern it responds to (an edge, a line, a blob). Layer-3 kernels act on feature maps of layer 2: their weights mix abstract channels, and only the feature maps, the most exciting image patches or occlusion experiments show what such a unit responds to.


Q6. You classify cells in microscope images whose orientation is arbitrary. Which augmentations would you use? Would you use the same for handwritten digits?

Which changes keep the label?

Cells: rotations by any angle, flips, small shifts, brightness and contrast changes, a little noise. Digits: small rotations and shifts only. A 6 rotated by 180° is a 9, and a mirrored 2 or 7 is not a digit at all.


Q7. (math) Two 3 \times 3 convolutions without a nonlinearity in between. Show that they are one convolution, and give its size.

Convolution is associative.

(x * k_1) * k_2 = x * (k_1 * k_2): one kernel k_1 * k_2 of size (3 + 3 - 1) \times (3 + 3 - 1) = 5 \times 5. Without the ReLU, depth adds no new kind of function, only a larger linear filter (the collapse argument of the first unit, in convolutional form).