Intuition edition. Every idea comes with an everyday example and something to try, and the maths stays to adding and multiplying. Read it before the lecture or the lab, or come back when a layer name stops making sense.
A CNN is a stack of reusable pattern detectors. Each one looks through a small window, and together they build from edges to objects.
Imagine cutting a photograph into thin strips and laying them end to end in one long line. Every pixel still has its number, but who was next to whom is gone. The eye of a cat is no longer near the nose.
Select a pixel. Its neighbours light up in both views.
Slide the face around the picture. A cat in the corner and a cat in the middle look like two unrelated puzzles to a flattened network.
Reading a street sign, you do not look at the whole city at once. You scan with a small field of view and notice local patterns: a corner, a stripe, a curve. A CNN neuron does the same with a small patch, say 3×3 pixels. That is local connectivity.
A detective has a template for "vertical stripe". She does not make a new template for every part of the photo. She slides the same one across the whole picture. At each position, multiply the patch by the template and add up. The total says how well the patch matches.
Select any square to move the plus sign. The same 9-number stamp slides over the whole picture. Add a second copy and it finds both.
Giving every pixel its own dial is wasteful. A phone photo has about 150,000 numbers.
The bar compares the 3×3 stamp (27 dials for a colour picture) with the 224-pixel flattened neuron.
One template finds one kind of pattern. A convolution layer uses a team of specialists in parallel: vertical edges, horizontal edges, a particular curve, a colour blob, a texture. Thirty-two filters give thirty-two feature maps stacked like a deck of transparent sheets, and each shows where its pattern appears.
Warm cells mean a strong match for that specialist. Grey cells mean the opposite pattern. A real layer runs 32 or more of these side by side.
Stride is how big a step the window takes. Padding is a frame of blanks around the photo. Pooling is making a thumbnail. These three settings decide how big the output is and how much detail it keeps.
A 6×6 picture with a 3×3 window gives 4×4 with no padding and stride 1, 6×6 with padding 1, and 2×2 with stride 2.
Select a square to raise its number by 1, up to 9. Each 2×2 block keeps only its largest value.
Almost every CNN repeats one three-beat rhythm. Think of airport security: scan the bag (conv), flag anything suspicious and ignore the rest (ReLU), file a one-line report per area (pool). The next officer reads the reports, not the bag.
Why ReLU? Without a non-linear step the stacked layers would collapse into one big linear operation.
Reading: letters build words, words build sentences. CNNs build understanding the same way. Stack 3×3 layers and see how much of the picture one neuron covers.
After many rounds of detect, filter and summarise, the last feature maps are handed to a small committee that votes. Softmax turns the votes into probabilities that sum to 100%.
Counted for 8×8 feature maps feeding a dense layer of 128 units.
Three habits keep a network steady and stop it memorising. Each has an everyday picture.
A football team that always trains with the same eleven becomes dependent on its star striker. Send a few random players home each session, and everyone learns to contribute.
In a relay race, each runner receives a baton of unpredictable size and weight. Now suppose each hand-over re-weighs and re-balances the baton. BatchNorm re-centres and re-scales each layer's numbers using the current mini-batch.
Usual order: Conv → BatchNorm → ReLU → Pool. At prediction time there is no mini-batch, so it uses the averages it collected during training. Two learned knobs let the network undo the rescaling if that helps.
A child who has only seen a cat sitting to the left may not recognise one facing right. Show the same cat flipped, tilted and zoomed, and the lesson sticks. Here a letter F stands in for the cat.
The goal: teach the network what should change and what should stay the same. Augmentation is applied only while training, never to validation or test pictures.
Before you change anything, read the curves. The training loss shows how well the network fits what it has seen. The validation loss shows how it does on pictures it has not. The four shapes below cover most of what you will meet. These are illustrative curves.
Saved in this browser only.