3.4.6 · D1Convolutional Neural Networks

Foundations — LeNet and AlexNet

1,765 words8 min readBack to topic

Everything below is a piece you must own before the parent note's layer tables make sense. We build each symbol from a picture, never from another symbol you haven't seen yet.


1. What an image actually IS to a computer

Before any math, look at what we are feeding the machine.

Figure — LeNet and AlexNet
  • The picture on the left shows a grayscale grid: rows going down, columns going across, each cell a number.
  • The picture on the right shows the same idea in colour: three stacked grids, one per colour. We call each grid a channel.

Notation you now own:

  • — height, width, channels. LeNet input . AlexNet input .

2. The filter (kernel) — a small pattern stamp

Figure — LeNet and AlexNet

Look at the figure: the orange window sits on the top-left of the image. Under it are 9 pixels; the filter has 9 weights. Multiply pairs, sum → the teal cell on the right is the answer.

  • = kernel size (one side). LeNet C1 uses , AlexNet Conv1 uses .
  • A filter always spans all input channels at once. So a filter on a 3-channel input actually holds weights.
  • Number of filters = how many different patterns this layer looks for. LeNet C1 has 6 filters → 6 output channels.

3. Sliding, stride, and padding

Now the key motion: how the filter moves decides the output size.

Figure — LeNet and AlexNet

Two pieces of that formula still need defining — do them now.

More on the sliding operation: Convolutional Layers.


4. Pooling — the shrink step

Figure — LeNet and AlexNet
  • LeNet uses average pooling (top of figure): gentle, cheap for 1998 hardware, spreads gradient to all inputs.
  • AlexNet uses max pooling (bottom): keeps the strongest response, better at "is the pattern present anywhere here?".

5. The activation function — the "keep or kill" gate

Between layers we pass every number through a simple function that adds the bending a network needs to learn non-straight patterns.

  • The symbol means "==pick whichever is larger, 0 or x=".
  • Why the switch matters (vanishing gradients, 6× speed) is developed fully in the parent note and in Activation Functions.

6. Symbols that show up in the innovations

You will meet these later in the parent note; own them now.

The training procedure that adjusts all these numbers is Backpropagation; later architectures that replace LRN and add stability are Batch Normalization, VGGNet and ResNet. Dropout gets its own deep treatment in Dropout.


7. How it all feeds the topic

Image as number grid H x W x C

Filter slides over patches

Stride and padding set output size

Output size floor formula

Activation tanh or ReLU

Pooling shrinks the grid

Stack many conv plus pool stages

Softmax gives class probabilities

LeNet and AlexNet

Read it top to bottom: pixels become patches, patches become scores, scores get bent and shrunk, stacked, and finally squeezed into class probabilities. LeNet and AlexNet are two ways of choosing the numbers in that pipeline.


Equipment checklist

Cover the right side and answer; reveal to check.

What does the shape mean?
Height × Width × Channels — a colour image is .
What is a filter (kernel)?
A small grid of weights slid over the image; each stop produces one output number by multiply-and-sum.
What does stride control?
How many pixels the filter jumps each move; bigger stride → smaller output.
What does padding do?
Adds a border of zeros so the filter can sit on edge pixels; shrinks the output.
Why is there a in the output-size formula?
A window that falls partly off the edge gives no output, so we round down the count of valid stops.
Compute output size for input 32, kernel 5, pad 0, stride 1.
.
Difference between max and average pooling?
Average keeps the mean of a window (LeNet); max keeps the largest value (AlexNet).
What is and what is it called?
ReLU — outputs if positive, else 0.
What does mean?
Elementwise (cell-by-cell) multiplication.
What does softmax produce?
Probabilities across the classes that add up to 1.
What is top-5 error?
Fraction of images whose true label is not in the model's 5 highest-probability guesses.