Receptive Field
The receptive field of a unit is the region of the original input that can affect it. A unit in a first convolutional layer with a kernel sees pixels. Each later layer looks at a neighborhood of the layer below, so the receptive field grows with depth. Along one axis, start from and . A layer with kernel size , dilation and stride updates them as
Here is the receptive field width of layer . The jump is the spacing between its neighboring units, measured in input pixels. A pooling layer with window and stride follows the same rule with . The receptive field grows in three ways:
- Depth: stride-1 layers with kernel size give , which grows linearly in .
- Downsampling: a stride or a pooling layer multiplies , so every later layer adds more input pixels.
- Dilation: a kernel with dilation covers inputs with only weights.
Intuition
To recognize a dog, a unit must see the whole dog, or at least enough of it. A first-layer unit with a kernel sees nine pixels, enough for an edge but not for an ear. Each layer looks at a neighborhood of the layer below, so the windows nest. In the figure a unit in sees three units of , which together see five inputs. Units deep in a network see most of the image even though every kernel is small.
\usepackage{tikz}
\begin{document}
\definecolor{cold}{HTML}{2F80ED}
\definecolor{mid}{HTML}{8A8A8A}
\begin{tikzpicture}[x=0.8cm,y=1cm]
\foreach \r/\y in {0/0,1/1.6,2/3.2} {
\foreach \i in {0,...,10} {
\node[circle,draw=mid,minimum size=0.36cm,inner sep=0pt] (n\r-\i) at (\i,\y) {};
}
}
\foreach \i in {3,4,5,6,7} \node[circle,draw=cold,fill=cold,minimum size=0.36cm,inner sep=0pt] at (\i,0) {};
\foreach \i in {4,5,6} \node[circle,draw=cold,fill=cold,minimum size=0.36cm,inner sep=0pt] at (\i,1.6) {};
\node[circle,draw=cold,fill=cold,minimum size=0.36cm,inner sep=0pt] at (5,3.2) {};
\foreach \i in {4,5,6} \draw[cold,thick] (5,3.02) -- (\i,1.78);
\foreach \i/\a/\b in {4/3/5,5/4/6,6/5/7} {
\foreach \k in {\a,...,\b} \draw[cold,thick] (\i,1.42) -- (\k,0.18);
}
\node[left] at (-0.5,0) {input $\mathbf{x}$};
\node[left] at (-0.5,1.6) {$\mathbf{H}_1$};
\node[left] at (-0.5,3.2) {$\mathbf{H}_2$};
\node[right] at (10.5,0) {$r = 1$};
\node[right] at (10.5,1.6) {$r = 3$};
\node[right] at (10.5,3.2) {$r = 5$};
\end{tikzpicture}
\end{document}Growing the window one layer at a time is slow. A image would need more than a hundred stride-1 layers before one unit could see all of it. Downsampling fixes this. After a stride-2 layer, neighboring units sit two pixels apart. The next kernel then reaches twice as far with the same number of weights.
Properties
(Downsampling Multiplies Growth) Stride and pooling multiply the rate at which the receptive field grows, while kernel size and dilation only add to it.
The update adds at each layer and multiplies by the stride. Without downsampling stays at , and each layer adds only pixels. A pooling with stride adds only itself, but it doubles for every layer that follows. After stride-2 layers or poolings, , and each later convolution adds pixels. This is why the receptive field of a CNN grows roughly exponentially in the number of downsampling stages.
(Stacked Small Kernels) Two stacked layers see the same window as one layer, with fewer weights and an extra nonlinearity.
With channels in and out, a single layer has weights. Two layers have . Three layers reach with weights instead of . The stack also puts a ReLU between the layers. It can therefore compute functions that one filter followed by one ReLU cannot. The VGG networks in 5.2.4. CNNs are built on this observation. A dilated kernel with reaches the same window with nine weights. It skips every other pixel inside that window.
(The Window Is an Upper Bound) The receptive field marks the inputs that can matter, and two effects shrink the part that does matter.
The first effect is the border. Near the edge of the image, padding fills part of the window. Edge units therefore see less real image than central units. The second effect concerns paths through the network. Every layer of a stack offers several routes from an input pixel to the output unit. A central pixel reaches the unit through many routes, while a pixel at the edge of the window reaches it through one. The influence is therefore concentrated near the center, a pattern known as the effective receptive field.
Not Taught in Lecture
The effective receptive field comes from Luo et al. (2016), not from lecture or Prince.
Take stride-1 layers whose kernels are all . The number of routes from input offset is the coefficient of in . These counts approach a Gaussian with standard deviation , which grows like while the window grows like . With the window is pixels wide, yet the central pixels carry of the routes.
Examples
(Medium) Receptive Field of a Stack
A network applies four convolutions in order: with stride , with stride , with dilation and stride , and with stride .
What is the receptive field of a unit in the last layer, and how many plain stride-1 layers would give the same receptive field? Apply and then , starting from .
layer 1 2 3 4 The last layer sees a window. Plain stride-1 layers add each, so they would need layers, all at full resolution.
(Medium) Two Linear Layers as One
Two stride-1 1D convolutions with kernel , no bias and no activation are applied in a row.
Which single kernel computes the same function, and what does it say about the receptive field? . The second sums three neighboring values: The stack equals one cross-correlation with the kernel . This kernel is the convolution of the two kernels. Its width is , matching the receptive field formula. The weights show the effective receptive field: the center pixel counts three times as much as either end. Without a nonlinearity in between, the two layers add no expressive power over a single -tap layer.
The first layer gives
(Hard) Designing for a Target Receptive Field
A network for images must have units whose receptive field covers at least pixels along each axis. It uses only convolutions with stride and max poolings with stride .
Compare a network with no pooling to one that pools after every two convolutions. needs layers, all at resolution. With pooling, each stage of two convolutions and one pooling updates the receptive field as follows:
Without pooling,
stage after two convs after pooling after pooling 1 2 3 4 The two convolutions of stage reach after eight convolutions and three poolings. The design needs a quarter of the convolutions. Most of them also run at low resolution, down to in the last stage. They cost far less than full-resolution layers.
See Also
- 5.2.1. Convolutional Layer, which defines kernel size, stride and dilation.
- 5.2.2. Pooling, the other way to downsample.
- 5.2.4. CNNs, where VGG stacks small kernels.
- 6.4. U-Net, which needs a large receptive field for every output pixel.