AI State of the Art
Fundamentals/Deep Learning: Fundamental Architectures/23 min
Section 17

Convolutional Neural Networks (CNN): Convolutions, Pooling, Feature Maps

Listen as a podcast β†’

Introduction: Why standard neural networks fail on images

A fully connected network (every neuron wired to every input) sees an image as a long vector.

Example: a 100x100 pixel color image (RGB, the three red, green, blue channels) = 10,000 pixels x 3 channels = 30,000 values.

The first hidden neuron has 30,000 inputs. With 1,000 hidden neurons, you have 30 million parameters. Huge. Slow. Inefficient. And each neuron uses every pixel in the image, regardless of where it is.

Convolutional Neural Networks (CNNs) exploit a simple property: nearby pixels are related.

An edge or important texture only occupies a few pixels. The appearance of a pattern (an eye, a wheel) is the same regardless of its position in the image. No need to learn separately for each position.

CNNs are inspired by the biological visual cortex: neurons don't receive the entire image, just a small local region.

Three operations recur throughout a CNN, and the diagram below chains them together:

  • the convolution, which looks for a pattern inside a small window;
  • the ReLU (Rectified Linear Unit), which passes positive values through unchanged and replaces every negative value with zero: either "this pattern is present, this strongly" or "it isn't here", with no negative values left to interpret;
  • the pooling, which shrinks what gets handed to the next layer.

All three are covered below.

Diagram of a convolutional neural network (CNN)
This diagram illustrates how a convolutional neural network (CNN) works for image classification. The input image is processed through convolution, ReLU, and pooling layers to extract features, before being classified via fully connected layers.

The convolution operation: the core mechanism

A convolution slides a small filter (kernel) over the image and computes a dot product (a kind of similarity score) at each position.

Result(i,j)=βˆ‘a,bImage(i+a,β€…β€Šj+b)Γ—Filter(a,b)\text{Result}(i, j) = \sum_{a,b} \text{Image}(i+a,\; j+b) \times \text{Filter}(a, b)

Every symbol:

  • ii and jj: the position at which the filter has been placed on the image (row ii, column jj);
  • aa and bb: coordinates inside the filter. For a 3x3 filter they run over the 9 cells;
  • βˆ‘a,b\sum_{a,b}: "sum over every cell of the filter";
  • Image(i+a, j+b)\text{Image}(i+a,\, j+b): the image pixel sitting under cell (a,b)(a, b) of the filter.

In one sentence: at each position on the image, multiply the pixels by the filter's numbers cell by cell, add it all up, and that single value becomes one pixel of the output image.

The result is a feature map: a new "image" that shows where that particular pattern appears and how intensely.

Example of 2D convolution with element-wise multiplication
This image illustrates the 2D convolution process: an input image is multiplied element-wise with a filter, then the values are accumulated to produce a feature map. This allows detecting specific patterns in the image.Source : ResearchGate

Concrete example: a filter that detects vertical edges:

Filter=[βˆ’10+1βˆ’20+2βˆ’10+1]\text{Filter} = \begin{bmatrix} -1 & 0 & +1 \\ -2 & 0 & +2 \\ -1 & 0 & +1 \end{bmatrix}

This filter has a name: it is the vertical Sobel filter, an edge detector used in image processing long before neural networks. Read it column by column: the left column counts negatively, the right column positively, the middle one not at all. So the result is near zero over a uniform area (left and right cancel out) and strongly positive or negative wherever intensity changes abruptly from one side to the other, that is, on a vertical edge.

Filtering a dog image with different convolution kernels
This image illustrates the effect of different convolution kernels on an original image. The edge detection filter highlights vertical intensity changes, revealing the contours of the image.Source : Medium

Filters learn patterns

The Sobel filter above was written by hand, by a human. In a CNN nobody writes it: the network discovers its filters on its own.

Each filter (typically 3x3 or 5x5) is a set of learned weights. One distinction to keep in mind from here on: the filter's weights are learned parameters, tuned during training and then frozen; the feature map is computed every time, on whichever image you are currently looking at. The filter is the tool, the map is the result of running it over the image.

Emergent hierarchy

Low layers (near the input): detect simple primitives. Horizontal edges, vertical edges, colors, contrast.

Middle layers: combine primitives to detect textures, simple shapes.

Deep layers: recognize complex structures. Eyes, wheels, faces.

This hierarchy emerges automatically without being coded.

Weight sharing

The same filter is applied everywhere in the image. This is powerful: few parameters (a 3x3 = 9 weights), and the network learns translation invariance (a pattern is detected no matter where it is in the image).

Example of weight sharing in a CNN
A convolutional neural network for a facial recognition application.Source : ResearchGate

Stride and padding: controlling the sliding

Two settings: the stride (the filter's step size) and the padding (the border added around the image).

Example of 2D convolution with 3x3 kernel
This image illustrates a 2D convolution operation on a 7x7 input matrix with a 3x3 kernel and a stride of 1. The result shows the computed value (114) after applying the kernel.Source : Analytics Vidhya

Stride

Comparison of convolutions with stride=1 and stride=2
The image illustrates the impact of the 'stride' parameter on the result of a convolution. On the left, with a stride of 1, the convolution window moves one pixel at each step, producing a more detailed output. On the right, with a stride of 2, the window skips a pixel at each step, reducing the output size.Source : Analytics Vidhya

It's the step size of the filter.

  • Stride 1: the filter moves one pixel at a time. Feature map of similar size.
  • Stride 2: the filter moves 2 pixels. Feature map half the size.

Larger stride = size reduction, fewer computations, but you lose local information.

Padding

Adding zeros around the image.

  • "Same" padding: adds enough zeros to maintain the dimensions
  • "Valid" padding: no zeros, dimensions shrink naturally

Padding helps when you want to keep the feature map size, or to treat border pixels properly (without a margin, a corner pixel is seen only once by a 3x3 filter, against nine times for a pixel in the middle).

Pooling: reducing resolution

Pooling (a downsampling step) reduces the size of feature maps. Three benefits:

  1. Fewer computations: subsequent layers work on less data
  2. Invariance: if a pattern shifts slightly, the max stays similar. Robustness to small translations
  3. Implicit regularization: fewer dimensions = less overfitting
Max Pooling and Average Pooling on convolution output
The image illustrates the application of Max Pooling and Average Pooling on a 4x4 convolution output. These operations reduce dimensionality while preserving the main features, improving computational efficiency and robustness to translations.Source : Jiang, Lu & Wang, Multimedia Tools and Applications (2019), figure 4, via Analytics Vidhya

Max Pooling

Takes the maximum in each window (typically 2x2). Preserves strong activations (salient patterns).

Average Pooling

Takes the average in each window. Used at the end to convert feature maps into a fixed-size vector.

Global Average Pooling

Global Average Pooling (GAP) replaces the fully connected layers at the end: take the average of each entire feature map, which gives one number per map. Dramatically fewer parameters, and it limits overfitting. Introduced in 2013 and popularized by GoogLeNet and ResNet (2014-2015), it has been the usual arrangement in classification CNNs ever since.

Hierarchy of representations: layer by layer

Each layer receives the feature maps from the previous layer. It applies multiple filters in parallel. If a layer has 64 filters, it produces 64 feature maps.

Each filter captures a different aspect. Together, they build a complete understanding.

Receptive field: the region we "see"

A deep neuron doesn't look at a single position. It "sees" a region of the input image. The deeper you are in the network, the larger this region becomes.

This is the receptive field. It grows with depth, allowing deep neurons to detect large objects and whole-image patterns.

A powerful technique to enlarge the receptive field without losing resolution or blowing up the number of parameters is dilated convolutions. Instead of sliding a 3x3 filter over adjacent pixels, you space out the sampled pixels, a 3x3 filter with dilation 2 samples every other pixel, so it covers a 5x5 area with only 9 weights. This is widely used in image segmentation and audio processing (WaveNet uses it to capture long-range dependencies in the signal).

Multi-Scale Context Aggregation by Dilated Convolutions (Yu & Koltun, 2015)

Example: a deep CNN can have a receptive field of 100x100 pixels. Each neuron in the deep layers "sees" a large area of the image.

Typical CNN architecture

Part 1: feature extractor

Convolution β†’ ReLU β†’ Pooling β†’ Convolution β†’ ReLU β†’ Pooling β†’ Convolution β†’ ReLU β†’ Pooling

A reminder of what each does: the convolution looks for patterns, the ReLU zeroes out anything negative, the pooling shrinks the result. Features become progressively more abstract, resolution decreases.

Part 2: classifier

Flattened features (the 3D maps are laid end to end into one long list of numbers) β†’ fully connected layers β†’ softmax, a function that turns raw output scores into probabilities summing to 1 ("87% cat, 11% dog, 2% everything else").

Or more modern: Global Average Pooling + 1x1 convolutions instead of fully connected layers (fewer parameters).

Beyond 2D images

CNNs are not limited to 2D images:

1D convolutions: process text, audio signals, time series. The filter slides along one dimension.

3D convolutions: process videos (two spatial dimensions plus time) and volumetric medical imaging, MRI (Magnetic Resonance Imaging) and CT (Computed Tomography, what people commonly call a scanner).

The principle remains: exploit the local structure of the data.

Common use cases

  • Classification: is it a cat or a dog?
  • Detection: where are all the cats in the image?
  • Segmentation: which class for each pixel?
  • Facial recognition: who is this face?
  • Medical imaging: detecting tumors
  • Autonomous vehicles: understanding the road
  • Style transfer: applying the style of a painting to a photo
CNNs aren't just for images

NLP (Natural Language Processing) used CNNs for text classification for a long time: the filter slides along the sentence instead of across the image. Effective and simple. Transformers (the architecture that has dominated language since 2017, see Transformer overview) took over, but CNNs are still used when short texts have to be classified fast.

Summary: why CNNs are revolutionary

CNNs made image analysis practical by keeping the number of parameters reasonable. An elegant architecture:

  • Few parameters thanks to weight sharing
  • Computationally efficient
  • Naturally captures the spatial structure of data
  • Learns a hierarchy of patterns automatically

That is what handed them computer vision from 2012 onward (AlexNet, see Classic CNN architectures).

Where things stand in 2026

CNNs dominated computer vision from 2012 to roughly 2021. Since then Vision Transformers (the transformer architecture applied to image patches instead of words) have taken the top spot on large vision tasks, provided you have plenty of data and plenty of compute. Convolution has not gone away: it remains the usual choice when training data is scarce, when the model has to fit on a device, and inside hybrid models that mix convolutions with attention.

Why this matters

Images are everywhere. CNNs give you the tools to analyze them. And two ideas introduced here (weight sharing, and a hierarchy of representations that emerges from training rather than being programmed) reappear, in other forms, in every architecture that followed.

Check your understanding0 / 5

1. Why is a fully connected network a poor fit for images?

2. In an already-trained CNN, what is frozen and what gets recomputed for each new image?

3. The same 3x3 filter is applied everywhere in the image. What is the double benefit of this weight sharing?

4. Are CNNs only for images?

5. In 2026, which statement best describes where CNNs stand in computer vision?