Convolutional neural network

Also known as: CNN

On this page 7

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.

LayerFunctionTypical settings
ConvolutionExtracts local features3×3 kernels, 32 to 512 filters
ActivationAdds nonlinearityReLU, GELU, SiLU
NormalizationStabilizes trainingBatch normalization after convolution
Pooling or strided convolutionReduces spatial resolution2×2 window, stride 2
Global average poolingCollapses each map to one valueBefore the classifier head
Fully connected headMaps features to outputsSoftmax for classification
Building blocks of a typical CNN

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.

HyperparameterCommon valuesEffect
Kernel size1×1, 3×3, occasionally 5×5 or 7×7Larger kernels see more context per layer
Stride1 or 2Stride 2 halves width and height
PaddingSame or validSame padding preserves spatial size
Dilation1, 2, 4Widens receptive field without extra weights
Number of filtersOften doubled after each downsamplingSets channel depth and capacity
Groups1, or equal to channels for depthwiseGrouped convolutions cut computation
Convolution hyperparameters and their effects

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.

ArchitectureKey ideaSignificance
LeNet-5Convolution and subsampling for digitsEarly practical CNN for handwriting
AlexNetDeep CNN trained on GPUs with ReLUBreakthrough on ImageNet in 2012
VGGUniform stacks of 3×3 convolutionsShowed the value of depth
ResNetResidual connectionsEnabled networks with over 100 layers
MobileNetDepthwise separable convolutionsEfficient models for mobile devices
EfficientNet and ConvNeXtBalanced scaling, modernized designCompetitive with vision transformers
Milestone CNN architectures

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.

ArchitectureCore operationTypical strength
Convolutional neural networkLocal shared filtersData-efficient vision, signals
Fully connected networkEvery input linked to every unitSmall tabular inputs
Recurrent neural networkState passed along a sequenceStreaming sequences, legacy NLP
Vision transformerSelf-attention over image patchesGlobal context, very large datasets
CNN and neighboring architectures

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.