Inside a CNN
Take your feature map from last lesson. Two formulas later you'll have built three layers of a real neural network.
- Apply ReLU to a feature map
- Shrink it with max pooling
- Trace an image through all four layers of a CNN
Inside a CNN
Take your feature map from last lesson. Two formulas later you'll have built three layers of a real neural network.
- Apply ReLU to a feature map
- Shrink it with max pooling
- Trace an image through all four layers of a CNN
Story
She points at the red band down the left side.
Learn it
A Convolutional Neural Network (CNN) is the deep-learning model that recognises images, and it is built from the operation you just learned, repeated in four kinds of layer. It finds features with many kernels, sharpens them, shrinks them, then weighs everything into a score for each label. The big difference from Lesson 4.4: nobody chooses the kernels. The network learns them from labelled images.
Words to know
a deep-learning model for images, with learnable weights and biases.
many kernels, each making a feature map (also called an activation map). Early layers find edges and colours; deeper layers combine them into shapes, then objects.
(Rectified Linear Unit) — turns every negative number into 0 and leaves positives alone, so useful features stand out.
shrinks a feature map while keeping what matters. Max pooling keeps the biggest number in each patch; average pooling keeps the average.
read a grid row by row into one long list.
gives every number in the list a weight for each label and adds them up into scores, like apple 0.93, pear 0.05.
Step by step: a 4 × 4 feature map through two layers
12 -5 0 8
-3 6 -9 2
4 0 7 -6
-1 9 3 5
- ReLU: every negative becomes 0 → rows become 12 0 0 8 · 0 6 0 2 · 4 0 7 0 · 0 9 3 5.
- Max pooling (2 × 2 blocks): top-left block {12, 0, 0, 6} → 12; top-right {0, 8, 0, 2} → 8; bottom-left {4, 0, 0, 9} → 9; bottom-right {7, 0, 3, 5} → 7.
- The pooled map is 2 × 2: 12 8 / 9 7. Sixteen numbers became four, and the strong features survived.
- Flatten: 12, 8, 9, 7.
- Fully connected: each of the four gets a weight for "apple" and for "not apple"; the sums become the two scores.
How it learns: a CNN starts with random kernels and weights, and adjusts them after every mistake (Lesson 2.4), until its kernels find the features that matter for its labels.
Careful: ReLU and pooling do not throw away what matters. ReLU drops what the next layer does not need, and pooling keeps the strongest signal in each patch, which is why the edge survives. And a CNN does not look for apples; it looks for patterns of numbers that came with the label apple.
Your missions
convolution.ods from Lesson 4.4ReLU
8 minin pairs- 1
Add a sheet named ReLU. In A1:
=MAX(0;$Output.A1). Fill it across to J and down to 10. - 2
Predict: what happens to the red band down the left of the apple? Write it down.
Only you can see this - 3
Give ReLU the same colour scale as Output. Were you right?
Max pooling
10 min- 4
Add a sheet named Pool. In A1, type
=MAX(OFFSET($ReLU.$A$1;(ROW()-1)*2;(COLUMN()-1)*2;2;2))— count the brackets: every one you open, you close. It finds the biggest number in each 2 × 2 block of ReLU. Fill it across to E and down to 5. - 5
Predict: the pooled map is 5 × 5. Will you still be able to see the edge of the apple?
Only you can see this - 6
Colour it. Count: how many numbers did you start with, after convolution, and after pooling?
Fully connected, on paper
5 min- 7
Read your 5 × 5 pool row by row into one list of 25 numbers — that is flattening.
- 8
A fully connected layer gives every one of the 25 numbers a weight for "apple" and a weight for "not apple", and adds them up. Which positions in your list would you give a big "apple" weight to? Why?
Change the pooling to average pooling: replace MAX with AVERAGE.
Compare the two 5 × 5 maps. Which keeps the edge sharper?
No laptop today?
Your teacher writes a 4 × 4 feature map with some negative numbers on the board. The class does ReLU aloud (every negative → 0), then max pooling into a 2 × 2, one block per row of desks. Then flatten the 2 × 2 into a list of 4 and discuss which should count most towards "apple".
Debate it
A CNN that recognises faces learned its kernels from millions of photos. Nobody can point to the kernel that means "eyes".
- If a face-recognition system wrongly matched a person to a crime, could anyone explain why? (Lesson 2.4's Think asked the same about neural networks.)
- Should a system nobody can explain be used to make decisions about people? Where would you draw the line?
Check yourself · practice, not a test
In the app, students answer these one at a time and each answer is checked straight away. It's practice, never a mark — anything they miss comes back later for another go.
1.Put the layers of a CNN in order:
- 1Convolution
- 2Pooling
- 3Fully connected
- 4ReLU
2.What does ReLU do to a feature map?
- AMakes it smaller
- BTurns negative numbers into 0 and keeps the positives
- CAdds a kernel
- DGives the final label
3.Max pooling on the 2 × 2 block (3, 7, 0, 5) gives:
- A3.75
- B0
- C7
- D15
4.In a CNN, a person chooses every kernel by hand.
TrueFalse5.The output of a convolution layer is called a feature ______.
Find features, drop the negatives, shrink, then vote.
Typing practice
Skill: a formula inside a formula (5 min)
-
On typing.com: the symbols lessons.
-
Type three times, eyes on the screen:
=MAX(OFFSET($ReLU.$A$1;(ROW()-1)*2;(COLUMN()-1)*2;2;2)) -
Count the brackets: every one you open, you close. Goal this term: 38–44 WPM at 95%.
Written and designed by Faizan Ayoub. © 2026 Faizan Ayoub. All rights reserved.