Skip to content
AI & MLadvanced

What is a convolutional neural network?

Updated Nov 30, 20263 min readBased on official documentation
What is a convolutional neural network?

In short

A convolutional neural network, or CNN, is a type of neural network that learns from grid-like data such as images. It slides small learned filters across the input to find local patterns like edges and textures, then combines them into higher-level features for tasks such as classification.

A convolutional neural network (CNN) is a neural network built around a special operation called convolution. It works well on data that has a grid structure, such as the pixels of an image, where nearby values are related to each other. Instead of treating every input value as independent, a CNN looks at small neighborhoods of values and learns which local patterns matter.

What problem it solves

A fully connected network connects every input value to every neuron in the next layer. For a large image, that means a huge number of weights, and the network has no built-in sense that a pixel is more related to its neighbors than to a pixel on the far side of the picture. Training such a model needs a lot of data and tends to overfit.

A CNN reduces this burden by reusing the same small set of weights across the whole input. The same filter that detects a vertical edge in the top-left corner also checks the bottom-right corner. This sharing of weights is the main reason CNNs became the standard tool for image work.

How it works

A convolutional layer holds a number of small filters, often called kernels. Each filter is a little grid of weights, for example 3 by 3. The filter slides across the input, and at each position it computes a weighted sum of the values underneath it. The results form a new grid called a feature map. Each feature map highlights where a particular pattern appears in the input.

After the convolution, the network applies an activation function. The glossary entry on activation functions explains that this step lets the network learn nonlinear relationships. Without it, stacking layers would add little beyond a single linear transformation. ReLU and sigmoid are common choices.

CNNs usually stack several layers. Early layers tend to respond to simple features such as edges and color changes. Deeper layers combine those into shapes and object parts. Pooling layers, which shrink the feature maps by summarizing small regions, are often placed between convolution blocks. The final layers are typically fully connected and produce the output, such as a probability for each class.

Training works like any other neural network. The model makes predictions, a loss function measures the error, and gradient descent adjusts the filter weights to reduce that error. The filters are learned from data rather than designed by hand.

When to use it

CNNs fit problems where the input has spatial or local structure. Typical examples include image classification, object detection, medical image analysis, and inspection of manufactured parts. They are also used for audio spectrograms and some time series, where a one-dimensional convolution can pick up local patterns over time.

They are less natural for data without a meaningful neighborhood, such as a simple table of unrelated columns. For that kind of data, gradient-boosted trees or a plain feed-forward network are often easier to train and to explain. Sequence tasks with long-range dependencies are now often handled by attention-based models, though CNNs remain useful as feature extractors.

Before choosing a CNN, check your evaluation plan. If your classes are imbalanced, a high accuracy score can hide a model that never predicts the rare class. Metrics such as precision and recall give a clearer picture in that case.

A simple example

Imagine a classifier that decides whether a small photo shows a cat or a dog. A CNN takes the image as a grid of pixel values, applies a set of learned filters, pools the results, and passes the final features to a dense output layer. Each output value is a score for one class. The class with the highest probability becomes the prediction.

When you test the model, you can use an ablation approach from the glossary. Remove one convolution block, retrain, and compare the results. If performance drops sharply, that block was carrying important information. If nothing changes, the block may be redundant and the model can be made smaller.

Common mistakes and limits

The first common mistake is ignoring the input scale. Normalizing pixel values before training usually makes optimization more stable. The second is using a model that is too large for the amount of labeled data. Data augmentation, such as flipping or cropping training images, helps reduce overfitting.

Another mistake is trusting a CNN blindly on data that differs from the training set. A model trained on daytime street photos may fail at night. Always test on data that reflects real conditions, and keep a separate test set that the model never sees during tuning.

Finally, CNNs can be hard to interpret. Visualizing feature maps and checking errors on specific examples are practical ways to see what the network has learned. For official definitions of related terms, the Google Machine Learning Glossary is a useful reference: https://developers.google.com/machine-learning/glossary

FAQ

Is a CNN the same as a deep neural network?

Not exactly. A CNN is a deep neural network that uses convolution layers. Many deep networks do not use convolution at all, so the two terms overlap but are not identical.

Why are CNNs so common for images?

Their filters look at small neighborhoods and reuse the same weights across the whole image. This needs fewer parameters than a fully connected network and matches how image patterns repeat across positions.

What is the difference between a filter and a feature map?

A filter is the small set of learned weights that slides across the input. A feature map is the grid of outputs produced when that filter has been applied across the whole input.

Can I use a CNN for data that is not an image?

Yes, when the data has local structure, such as audio spectrograms or sensor signals over time. Use one-dimensional convolutions for sequences and check that a simpler model does not perform as well.

Sources

This page is based on the official documentation below. Read it for full detail.

Convolutional neural network — official documentation ↗
blozhikDeveloper news from across the web, explained. Every story links to its original sources.