RECEPTIVE FIELD

Ch 4 ▸ Channels ▸ Module 3/4

  1. 1Color images
  2. 2Kernels with depth
  3. 3Many kernels
  4. 41×1 convolutions

Many kernels.

🔒 This module is locked

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

Go to Kernels with depth

One kernel finds one thing. Red minus blue found the duck, but it says nothing about edges, and the edge kernel says nothing about color. A convolution layer usually needs to find many things in the same image, so it has many kernels.

One map per kernel

Every kernel in a layer has the same shape, slides over the same input, and reads all of its channels. Each kernel makes its own output map. The layer’s output is all of those maps, stacked. Each map is one channel of the output, so

output channels=number of kernels.\text{output channels} = \text{number of kernels.}

The number of output channels is a choice the network’s designer makes, layer by layer. It doesn’t depend on the input: a layer with 64 kernels makes 64 channels whether its input has 3 channels or 300.

FIG 4.4 ▸ ONE LAYER, 4 KERNELS3 CHANNELS IN → 4 OUT

IN · 32×32×3

→

red − blue

blue − red

brightness

edge, all colors

OUT · 30×30×4

PARAMETERS = (3 × 3 × 3 × 4) + 4 = 112

Kernels
Every kernel reads all three input channels and makes one output map. The maps, stacked, are the layer's output: one channel per kernel. Red is above zero, blue below; each map has its own scale.

Figure 4.4 is one layer with four kernels, all from the last module. Its input is 32×32×3 and its output is 30×30×4. Turn kernels off, and the output loses channels. Each map is computed from the full input on its own; turning one kernel off doesn’t change the others.

The next layer

The output of one layer is the input of the next. So the second layer of a CNN reads a stack of 4 channels here, or 64 in a typical network, and each of its kernels has one slice per channel: 3×3×4, or 3×3×64. Those channels aren’t colors. Each one is a map of where one kernel of the previous layer found its pattern, and a kernel in the second layer combines them. It can look for, say, places where the duck’s color and an edge appear together.

Counting parameters

Each kernel has 3×3×Cin3 \times 3 \times C_\text{in} weights, where CinC_\text{in} is the number of input channels, and one bias. A layer has CoutC_\text{out} kernels, one per output channel. So, in the same form as chapter 1’s dense layer,

parameters=(3×3×Cin×Cout)+Cout\text{parameters} = (3 \times 3 \times C_\text{in} \times C_\text{out}) + C_\text{out}

where the + Cout+\,C_\text{out} is the biases, one per kernel. For figure 4.4 that’s (3×3×3×4)+4=112(3 \times 3 \times 3 \times 4) + 4 = 112.

Two layers of a real network, VGG-16:

Neither count depends on the size of the image. That’s chapter 1’s weight sharing again: the same kernels are used at every position. What the count does depend on is channels, in times out. Double both, and the weights go up four times. That’s why, among a CNN’s convolution layers, the deep ones with hundreds of channels hold most of the parameters.

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. 1A 3×3 convolution layer reads a color image and has 16 kernels. How many parameters does it have?

  2. 2A layer with 64 kernels reads an input with 3 channels. How many channels does its output have?

  3. 3The layer from the last question feeds a second 3×3 layer. How deep is each of the second layer’s kernels?

  4. 4A layer’s input doubles from 32×32 to 64×64, with the same channels and kernels. What happens to its parameter count?

0 of 4 answered correctly.

🔒 Next module: 1×1 convolutions