A convolutional neural network (CNN) is a type of deep neural network that processes grid-structured data, above all images, by sliding small learnable filters across the input and combining the detected local patterns into progressively more abstract features. Among neural networks, CNNs are defined by three ideas: local connectivity, weight sharing and spatial hierarchy.
These ideas build in a useful assumption about images, namely that nearby pixels are related and that a pattern means the same thing wherever it appears. As a result, CNNs need far fewer parameters than fully connected networks of similar capacity, and they became the dominant architecture for computer vision from the early 2010s until vision transformers began to compete with them.
How a convolutional neural network works
The core operation is the convolution, strictly a cross-correlation in most implementations. A filter, also called a kernel, is a small tensor such as 3 by 3 by the number of input channels. At each position, the network multiplies the filter element-wise with the underlying patch, sums the result and adds a bias, producing one value of a feature map. A layer with 64 filters produces 64 feature maps.
Because the same filter weights are reused at every position, a convolution layer is translation equivariant: shifting the input shifts the feature map in the same way. After each convolution, a nonlinear activation function, usually ReLU or a close variant, lets the network represent complex patterns.
Stacking layers enlarges the receptive field, the region of the input that influences one output value. Early layers respond to edges and color gradients, middle layers to textures and parts, and deep layers to whole objects. Weights are learned end to end with backpropagation and gradient descent.
| Layer | Function | Typical settings |
|---|---|---|
| Convolution | Extracts local features | 3×3 kernels, 32 to 512 filters |
| Activation | Adds nonlinearity | ReLU, GELU, SiLU |
| Normalization | Stabilizes training | Batch normalization after convolution |
| Pooling or strided convolution | Reduces spatial resolution | 2×2 window, stride 2 |
| Global average pooling | Collapses each map to one value | Before the classifier head |
| Fully connected head | Maps features to outputs | Softmax for classification |
Key hyperparameters of convolution layers
Each convolution layer is described by a small set of hyperparameters that control output size, receptive field and computational cost. For input width W, kernel size K, padding P and stride S, the output width is (W – K + 2P) / S + 1.
| Hyperparameter | Common values | Effect |
|---|---|---|
| Kernel size | 1×1, 3×3, occasionally 5×5 or 7×7 | Larger kernels see more context per layer |
| Stride | 1 or 2 | Stride 2 halves width and height |
| Padding | Same or valid | Same padding preserves spatial size |
| Dilation | 1, 2, 4 | Widens receptive field without extra weights |
| Number of filters | Often doubled after each downsampling | Sets channel depth and capacity |
| Groups | 1, or equal to channels for depthwise | Grouped convolutions cut computation |
A layer’s parameter count is K x K x input channels x filters, plus biases, and does not depend on image size. Two stacked 3×3 layers cover the same receptive field as one 5×5 layer with fewer parameters and an extra nonlinearity, which is why small kernels dominate modern designs.
Influential CNN architectures
The history of CNNs is a sequence of architectural ideas that made networks deeper, more accurate and more efficient.
| Architecture | Key idea | Significance |
|---|---|---|
| LeNet-5 | Convolution and subsampling for digits | Early practical CNN for handwriting |
| AlexNet | Deep CNN trained on GPUs with ReLU | Breakthrough on ImageNet in 2012 |
| VGG | Uniform stacks of 3×3 convolutions | Showed the value of depth |
| ResNet | Residual connections | Enabled networks with over 100 layers |
| MobileNet | Depthwise separable convolutions | Efficient models for mobile devices |
| EfficientNet and ConvNeXt | Balanced scaling, modernized design | Competitive with vision transformers |
Residual connections were particularly important: by adding a layer’s input to its output, they let gradients flow through very deep networks and largely solved the degradation problem seen in plain deep stacks.
CNNs compared with other neural network architectures
The choice of architecture reflects the inductive bias that suits the data. CNNs assume locality and translation equivariance, which helps with images but limits long-range reasoning in early layers.
| Architecture | Core operation | Typical strength |
|---|---|---|
| Convolutional neural network | Local shared filters | Data-efficient vision, signals |
| Fully connected network | Every input linked to every unit | Small tabular inputs |
| Recurrent neural network | State passed along a sequence | Streaming sequences, legacy NLP |
| Vision transformer | Self-attention over image patches | Global context, very large datasets |
With limited data, CNNs often train more efficiently than vision transformers because their built-in assumptions substitute for examples. With very large datasets, transformers can match or exceed them, and many current systems are hybrids that use convolutional stems with attention layers.
Applications, limitations and practical advice
CNNs are used for image classification, object detection, semantic segmentation, medical imaging, optical character recognition and quality inspection. One-dimensional CNNs process audio and sensor signals, and three-dimensional CNNs handle video and volumetric scans.
- Start from a pretrained backbone and fine-tune it, which is usually far better than training from scratch on a small dataset.
- Use data augmentation such as flips, crops and color jitter to improve generalization.
- Watch for shortcut learning, where the network keys on backgrounds or watermarks instead of the object.
- Expect limited rotation and scale invariance, which must come from augmentation or design.
- Inspect activation maps with methods such as Grad-CAM to verify that predictions rely on relevant regions.
CNNs are also vulnerable to adversarial perturbations, small and nearly invisible changes that alter predictions, which matters in safety-critical uses.
Explained without jargon
A convolutional neural network looks at a picture the way a person might scan it with a small magnifying glass. It moves the glass across the image and notices simple things first, such as edges and corners.
Then it combines those simple findings into bigger ones: edges become shapes, shapes become eyes or wheels, and those become a face or a car. The key point is that it builds understanding from small details up to whole objects, learning which details matter by studying many examples.
A typical use case
A manufacturer of printed circuit boards inspects every board with a camera at the end of the line. Engineers fine-tune a pretrained ResNet-style CNN on roughly 20,000 labeled images showing good boards and defects such as missing components, solder bridges and misaligned parts. Augmentation with small rotations and lighting changes reflects real variation on the line.
The model runs on an industrial computer at about 30 images per second, fast enough for the line speed. Boards with a defect probability above a set threshold are diverted for human checking. Compared with the previous rule-based vision system, the CNN catches more subtle solder defects and produces fewer false alarms when lighting changes, which reduces manual re-inspection and scrap.