What is a convolutional neural network (CNN)?
A convolutional neural network (CNN) is a neural network that processes grid-shaped data, such as images, by sliding small learned filters across the input. Each filter computes a dot product at every position and produces a feature map that marks where its pattern appears. Stacking convolution, ReLU, and pooling layers lets the network build from edges up to whole objects before a dense layer makes the final prediction.
CNNs are the standard model for image classification, object detection, segmentation, and medical imaging, and they also run on audio spectrograms and time series. Their strength comes from two constraints: each filter looks at a small local patch, and the same filter weights are reused at every position. That cuts the number of weights by orders of magnitude compared with a dense network and makes a pattern detectable wherever it appears in the image.
Key ideas
- A convolution slides a small kernel over the input and computes a dot product at each position.
- Weight sharing means one kernel detects its pattern anywhere in the image.
- Kernel values are learned by gradient descent, not designed by hand.
- ReLU keeps positive responses and zeros out the rest.
- Pooling shrinks feature maps and adds tolerance to small shifts.
- Deeper layers combine simpler features into parts and objects, then a dense layer classifies.
Common questions
What is the difference between a CNN and a regular neural network?
A regular (fully connected) layer connects every input to every output, so it ignores where pixels sit relative to each other. A convolutional layer connects each output only to a small local patch and reuses the same weights across positions. This gives far fewer parameters and builds in the assumption that nearby pixels are related.
What is a 1x1 convolution used for?
A 1x1 convolution mixes channels at each pixel without looking at neighbors. It is used to shrink or expand the number of channels cheaply, for example in the bottleneck blocks of ResNet and in Inception modules. It works like a small dense layer applied at every position.
Are CNNs still used now that vision transformers exist?
Yes. Vision transformers match or beat CNNs when trained on very large datasets, but CNNs are still common on smaller datasets, on phones and embedded devices, and as backbones for detection and segmentation. Many current models mix the two, using convolutions in early layers and attention later.
Can CNNs work on data other than images?
Yes. A 1D convolution slides along a sequence, so it works on audio waveforms, sensor readings, and text. A 3D convolution adds a time or depth axis for video and medical scans. Any data where nearby values are related is a good fit.
Related explainers
- Neural Networks — Neurons, layers, and how networks learn
- Pooling & Downsampling — Reduce spatial dimensions while preserving the most important features in feature maps
- Skip Connections & ResNets — Residual learning and why deeper networks work
- Batch Normalization — Why normalizing activations speeds up deep network training
- Object Detection — Locate and classify multiple objects in an image using bounding boxes and confidence scores
- Image Segmentation — Classify every pixel in an image — from semantic regions to individual object instances
References
- LeCun, Bottou, Bengio & Haffner (1998), "Gradient-Based Learning Applied to Document Recognition", Proc. IEEE
- Krizhevsky, Sutskever & Hinton (2017), "ImageNet Classification with Deep Convolutional Neural Networks", Communications of the ACM
- Zeiler & Fergus (2013), "Visualizing and Understanding Convolutional Networks"
- Stanford CS231n, "Convolutional Neural Networks"
Last updated