Convolutional Layers

What is the purpose of a convolutional layer?

A convolutional layer finds local patterns, such as edges and textures, in grid data like images. Learn how its learned filters do this and why it helps.

On this page
  1. The short answer
  2. The core job: finding patterns in small patches
  3. Why not use a fully connected layer?
  4. What the layer outputs
  5. Why stacking layers helps
  6. The settings a designer chooses
  7. Where the purpose shows up
  8. Common misunderstandings
  9. Putting it together

The short answer

A convolutional layer exists to find local patterns in grid-shaped data, such as the edges and textures in an image, and to find them wherever they appear. It learns a set of small filters from training data. Each filter scans the input and produces a map that shows where its pattern is present. The rest of the network uses those maps to make predictions.

The core job: finding patterns in small patches

A convolutional layer does not look at the whole input at once. It looks at a small window, usually 3×3 or 5×5 values, and computes a weighted sum over that window. Then it moves the window one step over and repeats the calculation. A large output value means the patch resembled the pattern that filter has learned to detect.

Because the same filter is reused at every position, a pattern found in one corner of an image is detected the same way in another corner. That is the key reason the layer suits images. The network does not have to learn the same pattern separately for every location.

Why not use a fully connected layer?

A fully connected layer links every input value to every neuron. For an image, that means a very large number of weights, and the layer has no built-in understanding that nearby pixels are related. It also has to learn a separate weight for each place a pattern might appear.

A convolutional layer handles both problems. It uses far fewer weights, because one small filter covers the whole image. It also keeps the layout of the image, so each output value still points to where the pattern was found.

What the layer outputs

Each filter produces a feature map. A feature map is a grid of values, one for each window position, where high values mark the places the filter’s pattern was found. A layer with several filters outputs several feature maps, and together they form the layer’s output.

In most designs, that output then passes through an activation function such as ReLU. Sometimes a pooling step follows, which shrinks the maps.

Why stacking layers helps

A first layer usually finds simple patterns, such as short edges. The next layer’s filters scan the feature maps from the first layer, so they can combine simple patterns into more complex ones, such as corners or simple shapes. Each layer in the stack sees a larger area of the original image than the one before it. This layer-by-layer build-up is a large part of why convolutional neural networks are preferred for computer vision applications.

The settings a designer chooses

A convolutional layer has a few choices that a designer sets before training. These are called hyperparameters:

  • Filter size: commonly 3×3 or 5×5.
  • Number of filters: this sets how many feature maps the layer produces.
  • Stride: how far the window moves at each step.
  • Padding: extra border values that control how the edges are covered and how large the output is.

The filter weights themselves are learned during training.

Where the purpose shows up

In a trained image model, early convolutional layers often respond to edges and changes in color. Middle layers combine those into textures and simple shapes, and later layers respond to larger parts of objects. The final part of the network uses these features to pick a label.

Convolutional layers are also used on audio spectrograms, where one axis is time and the other is frequency. The same idea of finding local patterns applies there.

Common misunderstandings

  • It is not a photo effect. Editing apps offer fixed filters, such as blur or sharpen, that a user picks. A convolutional layer’s filters are learned from data.
  • It does not see the whole image at once. It sees small patches. Depth, meaning the stack of layers, widens what the network can take into account.
  • It is not always the best choice. Vision Transformers use attention over image patches instead. Whether they beat a convolutional design depends on the data and the compute available.

Putting it together

The purpose of a convolutional layer is to detect local patterns with learned filters, output feature maps that show where those patterns appear, and do this with far fewer parameters than a fully connected layer would need. Stacked layers then combine simple patterns into more complex ones. For the step-by-step mechanics, see how do convolutional layers work in deep learning neural networks.

The complete guide to convolutional layers

How Convolutional Layers Work in Deep Learning Neural Networks
Read the guide

Keep exploring

Guides from other topics

All topics →