Home › Glossary › Computer Vision › Convolutional Neural Network (CNN)

Intermediate · Computer Vision

Convolutional Neural Network (CNN)

Visual diagram · Math · Worked example · 3 difficulty levels.

TL;DR. CNNs are neural networks designed for visual data. They use sliding filters to detect patterns like edges, shapes, and objects in images.

Intuitive Explanation

Imagine looking at a photo through a small magnifying glass that you slide across the entire image. Each position reveals a local pattern — an edge, a curve, a texture. Stack many magnifying glasses (each looking for different patterns) in layers, and you progressively see bigger features: edges → shapes → faces → people.

Technical Definition

A Convolutional Neural Network applies learned convolutional kernels (filters) that slide across spatial dimensions of the input, computing element-wise products and sums to produce feature maps. Combined with pooling layers for spatial downsampling and fully-connected layers for classification, CNNs exploit translation invariance and local connectivity for efficient spatial feature extraction.

How it works

CNNs revolutionized computer vision and remain foundational despite the rise of Vision Transformers. **Core Operations:** 1. **Convolution:** A filter (e.g., 3×3 matrix) slides across the input, computing dot products at each position to produce a feature map. Each filter learns to detect a specific pattern. 2. **Pooling:** Reduces spatial dimensions (e.g., 2×2 max pooling halves height and width). Provides translation invariance and reduces computation. 3. **Activation (ReLU):** Introduces non-linearity after each convolution. **Hierarchical Feature Learning:** - Layer 1: Edge detectors (horizontal, vertical, diagonal) - Layer 2: Corners, textures, simple shapes - Layer 3: Object parts (wheels, eyes, leaves) - Layer 4+: Whole objects, scenes **Key Architectures:** - **LeNet (1998):** Pioneer for handwritten digit recognition - **AlexNet (2012):** ImageNet breakthrough, launched the deep learning era - **VGG (2014):** Showed depth matters (16-19 layers with 3×3 filters) - **ResNet (2015):** Residual connections enabled training 150+ layer networks - **EfficientNet (2019):** Systematic scaling of depth, width, and resolution **Parameters vs Dense Networks:** A 3×3 filter has only 9 parameters but is applied at every spatial position — this parameter sharing makes CNNs vastly more efficient than fully-connected networks for image data.

Mathematical Notation

(f * g)(i,j) = ΣₘΣₙ f(m,n) · g(i-m, j-n)

The convolution operation slides kernel f over input g, computing element-wise products and summing them at each position (i,j) to produce one value in the output feature map.

Visual Explanation (layers)

Input Image → Conv + ReLU → Pooling → Conv + ReLU → Pooling → Flatten → Dense → Output

Real-World Use Cases

  • Apple: Face ID uses CNNs for facial recognition and depth perception
  • Google: Google Photos search and organization powered by CNNs
  • Waymo: Self-driving car vision systems use CNNs for object detection
  • Medical AI: CNNs detect cancer in medical imaging with radiologist-level accuracy

Related Concepts

  • Neural Network — A computing system inspired by biological neural networks that learns patterns from data through interconnected layers of nodes.
  • Activation Function — A non-linear function applied to a neuron's output, enabling the network to learn complex, non-linear relationships.
  • Deep Learning — A subset of machine learning using neural networks with many layers to learn hierarchical representations from large datasets.