CNNs: seeing with filters
A convolutional neural network (CNN) looks at images the way you scan a Where's Wally page: a small window sliding over the picture, hunting for one pattern at a time. That window is a filter: a tiny grid of weights, often 3×3. At each position, the filter multiplies its weights with the pixels underneath and sums, producing one number: "how strongly is my pattern present HERE?" Slide it everywhere and the numbers form a feature map, a heat map of pattern sightings.
Early layers learn filters for edges and corners. Deeper layers combine those into textures, then shapes, then whole objects: "vertical edge" → "goal post" → "goalkeeper". Nobody programs that ladder. It emerges from gradient descent, the algorithm you played in Lesson 2.
🎛️ Interactive: slide a real filter
Below is an 8×8 pixel image of a vertical stripe, and a 3×3 vertical-edge filter (+1 column, 0, −1 column). Use the arrows (or tap a pixel) to move the orange window, and watch the sum. The filter shouts (big absolute number) exactly where the stripe's edges are, and shrugs (0) on flat areas.
The image (8×8)
The filter (3×3)
Feature map (6×6)
Do one filter position by hand
Move the window until the readout says row 1, column 4. Its left column now sits on the stripe, so every row of pixels under the window reads 1, 1, 0: stripe, stripe, background. Multiply each pixel by the filter weight sitting on top of it, then add all nine products:
Now try the same arithmetic where the window sees only background: all nine pixels are 0, every product is 0, sum 0. And if the window sat on a patch that was ALL dark, the +1 column would score +3, the −1 column would score −3, and they would cancel back to 0. That cancellation is the design, not an accident: this filter ignores flat regions entirely, bright or dark, and only speaks up where the left side of its window differs from the right side. Which is, precisely, a vertical edge.
Suppose you wired every pixel of this 8×8 image to all 36 feature-map cells the dense way, like Lesson 1: that is 64 × 36 = 2304 weights to learn, for one toy image. The sliding filter does the job with 9 weights, reused at all 36 positions. And the reuse is not just cheap, it is correct: a vertical edge looks identical at the top of a photo and at the bottom, so ONE detector, learned once, works everywhere. This weight sharing is the reason CNNs can chew through megapixel satellite images without needing a separate weight for every pixel.
LSTMs: remembering through time
Now flip from space to time. Tomorrow's temperature depends on the RUN of recent days, in order. A recurrent neural network (RNN) processes a sequence one step at a time while carrying a hidden memory forward, like reading a novel and keeping the plot in your head. Plain RNNs are forgetful over long stretches, so the field's workhorse is the LSTM (long short-term memory), which adds gates: little learned valves deciding, at every step, what to keep, what to forget, and what to output. You met an LSTM briefly in Week 3. Now you know what the gates are doing.
🎛️ Interactive: the forget gate
Watch a memory cell read seven days of temperatures. The forget gate f controls the blend: memory = f × old memory + (1 − f) × today. Slide it and press play. High f = long memory (smooth, slow to react). Low f = goldfish memory (chases every wobble).
Memory: –
Run the forget gate by hand
Three days of Kingston temperatures: 30.0°, 28.0°, 32.0°. The memory starts at Day 1's value, 30.0. Watch how the gate setting changes what the cell believes by Day 3. First, a long memory, f = 0.9:
Day 3: (0.9 × 29.8) + (0.1 × 32.0) = 26.82 + 3.2 = 30.02
Now a goldfish memory, f = 0.1, on the exact same days:
Day 3: (0.1 × 28.2) + (0.9 × 32.0) = 2.82 + 28.8 = 31.62
Same three days, two different beliefs: the long memory ends at 30.02°, barely moved by the swings, while the goldfish ends at 31.62°, glued to whatever happened last. Neither is wrong in general. Slow trends want a high f; jumpy signals want a low one. The LSTM's real trick is that it never makes you choose: f is learned from data, and because the gate is itself a tiny neuron, it can open and close differently at each time step, holding the trend through ordinary days and dumping the memory when a cold front rolls in.
It feels like the network must keep all seven days on file somewhere to use them. It keeps none of them. The cell carries one compressed running summary, and each new day overwrites it. Old days survive only as fading traces: with f = 0.6, Day 1's contribution gets multiplied by 0.6 at every update, so three days later it is 0.6 × 0.6 × 0.6 ≈ 0.22, roughly a fifth of its original strength. That fade is exactly why plain RNNs, which cannot control the blend, forget long stories, and why learnable gates were a breakthrough: the network can push f close to 1 and carry one important fact for hundreds of steps.
Week 3's 5-day rolling average was already a memory cell, just a frozen one: it blends recent days with fixed weights and can never adapt. Cricket fans run one in their heads too. A batter's "form" is a running impression of recent innings, weighted toward the latest ones, updated after every match, long after the scorecard details are forgotten. The LSTM is that same instinct with the blend turned into learnable parameters, so the data itself decides how long the memory should be.
Which tool for which job?
Inputs are a table of match stats: rankings, goals, form. No image, no long sequence, so a plain dense network (the Lesson 1 kind) is the right tool.
An ordered sequence of past days. An LSTM reads it in order and carries the trend in its memory cell.
Pictures = CNN. This is genuinely how storm intensity models read satellite data over the Caribbean.
Sequences again, but modern chatbots replaced LSTMs with transformers, which is exactly where Week 6 begins.
You want to predict tomorrow's max temperature from the last 14 days of readings. Which architecture fits best?
1) CNNs slide small filters over images to build feature maps; depth turns edges into objects. 2) LSTMs read sequences in order, with gates that learn what to remember and forget. 3) Match the architecture to the data's shape: tables → dense, images → CNN, sequences → LSTM (or transformers, coming in Week 6).
Next: press Train and watch a real network learn, live in your browser.