Mikhail Mikhasenko · Lecture 3B
A colour image is a tensor of pixel intensities: height × width × 3 channels (red, green, blue).
AlexNet reads a 224 × 224 × 3 tensor, 150 528 numbers, and returns 1000 probabilities, one per ImageNet class.
Inside there is nothing but the neurons of Lecture 3A: weighted sums, ReLUs, and a softmax at the end.
The new idea is how the weights are arranged.
![]()
| class | probability |
|---|---|
| Egyptian cat | 0.80 |
| tiger cat | 0.13 |
| tabby | 0.07 |
Small enough for a laptop, hard enough to separate methods.

| Model | Details | Test error |
|---|---|---|
| Linear classifier | pairwise, deskewed inputs | 7.6 % |
| Random forest | fast unified random forests | 2.8 % |
| Boosted stumps | on Haar features | 0.87 % |
| Support-vector machine | degree-9 polynomial, jittered | 0.56 % |
| Neural network | 784–800–10, no distortions | 1.6 % |
| Deep neural network | 784–2500–2000–1500–1000–500–10, elastic distortions | 0.35 % |
| Convolutional network | committee of 35 CNNs | 0.23 % |
| Convolutional network | ensemble of 3 CNNs, augmentation | 0.09 % |
Dense networks need hand-made distortions to compete. Convolutional networks build in what images are like.
One dense layer from a 224 × 224 × 3 image to 4096 units:
A dense unit treats pixel 17 and pixel 17 000 as unrelated inputs. Shift the cat by a few pixels and every input changes.
Locality: nearby pixels belong together; an edge is a local pattern.
Translation: a pattern means the same thing anywhere in the image.
So: use small detectors, and apply the same detector at every position.
Slide a small grid of weights, the kernel, over the image. At each position take the dot product of kernel and patch:
Large when the patch looks like the kernel: a similarity score.

AlexNet kernel 9 (left) slid over an image that contains its own pattern, upright and rotated by 90°. Activation map (right): peak 9.0 on the upright copy, 0.0 on the rotated copy.
For one kernel of size , bias , stride and padding :
Output size for an input:
AlexNet conv1: .
Deep-learning “convolution” does not flip the kernel; mathematicians call it cross-correlation.
A kernel always spans all input channels: weights.
kernels give activation maps. Stacked, they form a new tensor .
The next layer processes it exactly like an image, only with “colours”.
Parameters: .
| Weights | Share of AlexNet | |
|---|---|---|
| conv1: 64 kernels of 11 × 11 × 3, plus biases | 23 296 | |
| a dense layer with the same 55 × 55 × 64 outputs | ||
| all 5 convolutional layers | 2.5 M | 4 % of weights, 92 % of computation |
| the 3 dense layers | 58.6 M | 96 % of weights, 8 % of computation |
Weight sharing cuts conv1 by a factor of a million. The convolutional layers are cheap to store but expensive to run: every weight is used at thousands of positions.
Max pooling keeps the largest value in each window:
| 1 | 3 | 2 | 0 |
| 4 | 2 | 1 | 5 |
| 0 | 1 | 3 | 2 |
| 2 | 6 | 1 | 0 |
| 4 | 5 |
| 6 | 3 |
2 × 2 window, stride 2: a quarter of the values survive.
No weights to learn. AlexNet uses overlapping 3 × 3 windows with stride 2.
flatten dense layers softmax
Features first, then a classifier: the dense end is the MLP of Lecture 3A.
32 × 32 digit → 6 maps 28 × 28 → pool → 16 maps 10 × 10 → pool → 120 → 84 → 10. About 60 000 parameters; read bank cheques in the 1990s.
| AlexNet layer | pixels seen by one unit |
|---|---|
| conv1 | 11 × 11 |
| conv2 | 51 × 51 |
| conv3 | 99 × 99 |
| conv5 | 163 × 163 |
Deep units see large parts of the 224 × 224 image.
MNIST digits are centred. Move every test image a few pixels to the right and measure again.
| shift | 0 px | 2 px | 3 px |
|---|---|---|---|
| dense 784–128–10 | 96 % | 75 % | 47 % |
| boosted trees (JLBoost) | 90 % | 69 % | 51 % |
| CNN | 97 % | 91 % | 74 % |
Trees and dense networks see each pixel as a fixed input. The CNN applies the same kernels everywhere and pools.
ILSVRC 2010–2017: 1.2 million training images, 1000 classes. Score: top-5 error, the fraction of images whose true class is not among the five best guesses.
Before 2012: hand-designed features (SIFT, Fisher vectors) and linear classifiers.
2012, AlexNet (Krizhevsky, Sutskever, Hinton): 16.4 %, against 26.2 % for the runner-up.
After 2012 every winner was a deep convolutional network.
(CONV → RN → MP)² → CONV³ → MP → (FC → DO)² → Linear → softmax
CONV: convolution + ReLU · RN: local response normalization · MP: max pooling · FC: dense + ReLU · DO: dropout
The algorithms were from the 1980s. The scale of data and compute was new.

Each first-layer kernel has depth 3, like the image, so it is a tiny RGB picture.
Every kernel started as random numbers. These patterns were learned from labelled photos alone.


Sliding each of the 64 kernels over the photo gives 64 activation maps (55 × 55 after ReLU).
A map is bright where the image looks like its kernel: whiskers, eye outlines, fur texture, the pink nose.

input: a sheet of paper

all 192 conv2 maps

channel 94: corners
Layer-2 kernels are 5 × 5 × 64: we cannot draw them, but we can watch what they respond to. Most maps trace edges of the square; channel 94 fires almost only at its corners.

conv5, channel 174 · peak activation 14.5 on the astronaut’s face, 0.8 with the face covered, 14.5 on the cameraman, 5.8 on the cat’s nose. ImageNet has no “face” or “person” class.

conv1 · 9
stripesconv2 · 94
cornersconv3 · 150conv4 · 60conv5 · 174
eyes, nosefc8 · goldfish
Start from noise and change the image by gradient ascent until one unit is as active as possible; the weights stay fixed. Deeper units prefer textures, patterns, object parts.
| image | top prediction |
|---|---|
| espresso 0.97 | |
| tripod 0.72 | |
| mosque 0.63 | |
| dumbbell 0.27 |
There is no “rocket” or “astronaut” class. A classifier always picks one of its labels.

Occlusion: grey out a patch, record p(Egyptian cat). Covering the eyes hurts most (0.80 → 0.51).
Stop before the classifier: every image becomes a point in a 4096-dimensional space (fc7). Flipped and cropped copies of the same photo: similarity 0.34 in pixels, 0.83 in the embedding.
AlexNet_under_the_hood.py loads the pretrained network and lets you
From the Lecture_3B folder:
Runs on a laptop CPU; the first start downloads the weights (~240 MB).
VGG (2014): only 3 × 3 kernels, 16–19 layers. Two 3 × 3 layers see 5 × 5 with fewer weights.
GoogLeNet (2014): 22 layers of parallel “inception” branches.
ResNet (2015): 152 layers, 3.6 % top-5 error. Each block learns a correction to its input:
The skip connection gives gradients a direct path back through many layers: the vanishing-gradient problem of Lecture 3A, solved by architecture.
Since 2020, vision transformers cut images into patches and treat them like words, using the same blocks as language models. Their “Add & Norm” is ResNet’s skip connection.
| LeNet-5 | AlexNet | GPT-3 | |
|---|---|---|---|
| Year | 1998 | 2012 | 2020 |
| Data | MNIST: 60 000 images, 10 classes | ImageNet: 1.2 M images, 1000 classes | ~300 billion tokens of text |
| Compute | one CPU | two gaming GPUs | thousands of data-centre GPUs |
| Parameters | ~60 000 | ~60 million | 175 billion |
| Layers | 5 | 8 | 96 |
| Key parts | convolutions, tanh | convolutions, ReLU, dropout | transformer blocks with dense layers |
The same building blocks, scaled up by factors of a thousand at every step.
Thank you for the attention