XenonStack Glossary: AI, Data and Cloud Terms Explained

What Is Convolution? CNN Basics Explained

Written by Dr. Jagreet Kaur | 17 Mar 2023

Convolution is a mathematical operation that slides a small filter, also called a kernel, across an input and combines the values under it, and it is the foundation of convolutional neural networks (CNNs), which excel at identifying edges and objects in images. Each position the filter visits produces one output value, and together those values form a map of where a feature appears.

This page is for data scientists, engineers and technology leaders who need a clear definition of convolution. It covers how the operation works, the key terms, how it differs from pooling and fully connected layers, and where it fits when you build AI agents that work with images.

What is convolution in deep learning?

In a convolutional layer, a small tensor called a kernel is slid across the input. As the Dive into Deep Learning textbook notes, the kernel values are learned during training, and the layer's output is often called a feature map.

The same book points out that the term is a slight misnomer. Strictly, the operation is cross-correlation, and a true convolution flips the kernel first. Because kernels are learned from data, the outputs are the same either way, so deep learning uses the word convolution for both.

Why does convolution matter?

Images have local structure: nearby pixels tend to belong together. Convolution exploits this by connecting each output to a small region of the input instead of to every pixel. The Stanford CS231n notes call this local connectivity, and the small region is the neuron's receptive field.

Convolution also shares parameters. All neurons in one depth slice use the same weights, which, as the same notes explain, greatly reduces the number of parameters compared with connecting every input to every neuron.

How does convolution work?

  • Filter or kernel: a small window of learned weights. In CS231n a filter is small in width and height but extends through the full depth of the input, for example across all three colour channels.
  • Sliding and dot products: the filter moves across the input and computes a dot product at each position, producing a two-dimensional activation map. One map per filter is stacked to form the output.
  • Stride: the step size of the slide. A stride of 2 moves two pixels at a time and gives a smaller output.
  • Padding: zeros added around the border so the kernel can reach the edges and the output size can be preserved.
  • Receptive field: all the earlier elements that can affect the value of one element.

For an input of width W, filter size F, stride S and padding P, CS231n gives the output width as (W minus F plus 2P) divided by S, plus 1. A 7 by 7 input with a 3 by 3 filter, stride 1 and no padding gives a 5 by 5 output.

How does convolution differ from pooling and fully connected layers?

LayerWhat it doesLearnable parameters
ConvolutionSlides shared filters over the input to detect local featuresYes, the kernel weights and biases
PoolingReduces spatial size, often by taking the maximum in each windowNone
Fully connectedConnects every input to every neuronYes, one weight per connection

CS231n notes that pooling is usually inserted between convolutional layers to reduce spatial size, computation and overfitting.

How does convolution relate to AI agents?

Agents that inspect images, such as scanned documents, photographs or camera feeds, rely on vision models that are built from convolutional layers or related designs. The agent still needs governed access to the data and decisions around that model. For teams building and running agents, ElixirClaw is XenonStack's AI agents computing platform.

What should you do first?

  1. Decide what the model must detect: edges, objects or defects.
  2. Start from an existing pre-trained convolutional network.
  3. Check that input size, stride and padding give the output shape you expect.
  4. Evaluate on images from your own setting before deployment.

To map one decision your agents make from image analysis, and the data and policy it depends on, book a Context Workshop. See what happens in the workshop.

Frequently asked questions

What is convolution in simple terms?

It is an operation that slides a small filter across an input and combines the values under it at each position. The results form a map showing where a feature appears.

What is a kernel in a convolutional layer?

A kernel is a small tensor of learned weights that is slid across the input. Its height and width define the convolution window.

Is convolution the same as cross-correlation?

Strictly no, because a true convolution flips the kernel first. In deep learning the kernels are learned, so the outputs are the same and both are called convolution.

What are stride and padding?

Stride is the step size of the filter as it slides across the input. Padding adds zeros around the border so the kernel can reach the edges and the output size can be preserved.

Why are CNNs good at images?

They connect each output to a small local region and share the same filter weights across the image. This suits the local structure of images and reduces the number of parameters.