Convolutional Neural Networks

A convolutional neural network is a two-dimensional scanning network designed for data with spatial structure, such as images. A CNN applies the same learned local function (a convolutional kernel) to many overlapping spatial patches of the input, producing feature maps that detect patterns regardless of their position.

Given an input , a convolutional layer applies a bank of filters, each of size . The -th filter produces an feature map,

where is a nonlinearity such as ReLU. Note that padding is frequently employed to restore the feature map to the shape of the original input, such that in general, padding by rows and columns leads to a shape of . If convolution is done with a stride of , then the dimension of the output is

A CNN therefore inherits the key properties of scanning networks:

  • Sparse connectivity: each neuron sees only an patch.
  • Shared connectivity pattern: the same kernel weights are reused at every spatial location.
  • Shift equivariance: shifting the input produces a corresponding shift in the activation map.

Stacking convolution layers grows receptive fields hierarchically, enabling early layers to detect edges and later layers to capture textures, shapes, and object-level structure. Optional pooling layers (max-pooling or average-pooling) downsample spatial dimensions by aggregating over local neighborhoods, providing robustness to small shifts and scale variations:

After several such layers extract increasingly abstract features, the final spatial representation is flattened and passed to one or more fully connected layers that compute the output

Examples

Convolution Operation in CNNs

In this question, we will look at the mechanism of weight sharing in convolutions. Suppose that we have an input vector with dimensions:

We compute a 1D convolution with the kernel filter that has weights (parameters):

Recall that CNN filters have the property of weight sharing, meaning that different portions of an image can share the same weight to extract the same set of features. A convolution is actually a linear operation, which we can express as for some weight matrix .

Consider now a 2-dimensional example with the following image and kernel filter: