Deep Learning · Step 3 of 8 · 9 min
CNNs for images
You know why convolutional networks suit images and how to reuse a pretrained one.
The problem with plain layers
A small colour photo of 224 by 224 pixels is about 150,000 numbers. Connecting each of them to every neuron in a plain layer needs millions of weights, and the network has to learn separately that a cat in the top corner is the same as a cat in the middle.
Convolutions: one small filter, slid everywhere
A convolutional layer learns small filters, often 3 by 3 pixels. Each filter slides across the whole image and responds wherever it finds its pattern, such as a vertical edge. The same few weights are reused at every position. That makes CNNs efficient and naturally good at finding a pattern wherever it appears.
Pooling layers or strided convolutions then shrink the image step by step. Each stage sees a wider area, so the network builds from edges to textures to parts to whole objects.
Transfer learning is the normal way
You rarely train an image model from scratch. You take a network already trained on millions of images, such as a ResNet or EfficientNet, replace its last layer with one for your classes, and fine-tune it on your data. A few hundred labelled images per class can be enough.
Vision transformers, which split an image into patches and use attention, now match or beat CNNs on many tasks, especially with lots of data. CNNs remain common, fast and a good place to learn.
Try it
Look inside a CNN
- 1.Open CNN Explainer at poloclub.github.io/cnn-explainer in your browser.
- 2.Click a filter in the first layer and see which parts of the image it lights up.
- 3.Follow one image through the layers to the final class scores.
- 4.Then ask a chatbot the prompt below to check your understanding.
Explain in five short sentences why a convolutional layer needs far fewer weights than a fully connected layer for a 224x224 image. Use a concrete number example.