What is Convolutional neural network (CNN)?

A neural network built mainly from convolutional layers, which slide small filters (kernels) over the input and compute sums of products, stacked with pooling layers and others. Because the same filter is reused over the whole input, it has far fewer parameters than fully connected layers and extracts local features such as edges and textures in an image regardless of their position. It is used for image recognition, object detection, audio processing and more.

Japanese name: 畳み込みニューラルネットワーク(CNN)

Convolutional neural network (CNN) appears in 2 practice questions across 2 topics, including AI Hardware & Software Stack, Machine Learning Basics.

Field: Machine Learning Basics

Computation in a convolutional layer

A convolutional layer slides, for example, a 3×3 filter from the top left of the image at a fixed step (the stride), computing the sum of products of the overlapping pixels and the filter weights to build a feature map. The output size is (N + 2P − F) ÷ S + 1 for input size N, filter size F, padding P and stride S. Each layer uses several filters, each extracting a different feature such as vertical edges, horizontal edges or color changes. Deeper layers respond to larger, more complex features such as eyes or wheels.

Why it needs few parameters

A convolutional layer that applies 64 filters of size 3×3 to a 3-channel input has 3 × 3 × 3 × 64 + 64 = 1792 parameters, independent of the image size. Connecting the same 32×32×3 image to a fully connected layer with 64 outputs needs 32 × 32 × 3 × 64 + 64 = 196672 parameters. Looking only at nearby pixels (local connectivity) and reusing the same filter everywhere (weight sharing) let it learn efficiently with few parameters.

Pooling and overall structure

A pooling layer takes the maximum (max pooling) or average over regions such as 2×2 to shrink the data, reducing computation and making the network less sensitive to small shifts in position. A typical CNN stacks several groups of convolutional layer, activation function (such as ReLU) and pooling layer, and finally classifies with fully connected layers and a softmax function. Residual connections, which carry signals past layers, make it possible to train networks deeper than 100 layers.

Try it: questions about Convolutional neural network (CNN)

Why are convolutions in CNNs sometimes converted into matrix multiplications, for example with im2col?

  1. AConversion reduces the operation count tenfold
  2. BSo that highly optimized matrix-multiplication libraries and matrix units such as tensor cores can be used
  3. CConversion always reduces memory usage
Show answer and explanation

Answer: B. So that highly optimized matrix-multiplication libraries and matrix units such as tensor cores can be used

im2col builds a large matrix in which the input values of each convolution window are laid out as a column, then computes the convolution as a product with a matrix of filters. Overlapping windows duplicate input values and increase memory, but decades-optimized matrix-multiplication libraries and matrix units such as tensor cores can be used directly, so it is often faster overall. Some implementations achieve the same effect without materializing the duplicates.

FAQ

Is the computation in a convolutional layer the same as mathematical convolution?

Most frameworks call convolution what is strictly cross-correlation, a sum of products taken without flipping the filter. Because the filter weights are learned, whether the filter is flipped makes no difference to the model's performance.

Can CNNs be used for things other than images?

Yes. One-dimensional convolutions are used for audio waveforms and time-series data, and three-dimensional convolutions for video and volumetric medical images. They suit data arranged on a grid, in which neighboring values are related.

Convolutional neural network (CNN) in the explanations

Questions that mention Convolutional neural network (CNN) (2)

  1. Why are convolutions in CNNs sometimes converted into matrix multiplications, for example with im2col?
  2. Which of the following describes transfer learning, in which a model trained on a large amount of data is used for a different task with little data?

Books on Machine Learning Basics Ad

As an Amazon Associate I earn from qualifying purchases.

Semiconductor, Electronics and Computing Calculators

Related terms

Convolution Transfer learning Activation function Confusion matrix Cross-validation Gradient descent k-means clustering Overfitting Precision and recall Principal component analysis (PCA)

Back to the glossary