Seeing and remembering: CNNs & RNNs
Special network shapes for images and sequences, and why they mattered.
A plain network treats every input pixel as unrelated. But pixels next to each other belong together, and words in a sentence come in order. Two architectures were built to respect that structure.
๐ผ๏ธ Convolutional Neural Networks (CNNs)
A small filter (say 3ร3) slides across the image, checking each patch for a pattern like an edge.
The same filter is reused everywhere, so a cat ear is recognised wherever it appears and the model needs far fewer weights.
๐๏ธ Feature hierarchy
Stack conv layers with pooling (downsizing) in between.
Early layers find edges โ then textures โ parts (eyes, wheels) โ whole objects.
AlexNet's win in the 2012 ImageNet competition kick-started the deep learning boom.
Why do CNNs reuse the same filter across the whole image?
๐ Recurrent Neural Networks (RNNs)
Read a sequence one step at a time, carrying a hidden state, a running memory of what came before.
Used for text, speech, and time series before 2017.
๐ง LSTMs: better memory
Plain RNNs forget long-ago inputs (vanishing gradients again).
LSTMs add gates that learn what to remember, forget and output, so they hold on to context much longer.
โฉ Why transformers took over
RNNs read word by word, so they can't easily be parallelised and still struggle with long text.
Transformers (Advanced level!) look at every word at once with attention. Today they dominate language and are increasingly used for images too (Vision Transformers).
What does an RNN's hidden state do?
โจ Before you drift off
- CNNs slide shared filters over images to detect local patterns.
- Layers build from edges to objects.
- RNNs/LSTMs process sequences with a running memory.
- Transformers replaced RNNs for most language tasks.
๐ Go deeper (free & open)
- CNN Explainer (interactive) โ ยท Wang et al., Georgia Tech Polo Club ยท MIT licensed
- CS231n: Convolutional Neural Networks for Visual Recognition โ ยท Stanford University
- Understanding LSTM Networks โ ยท Christopher Olah