Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Convolutional Neural Networks

1. Motivation

Fully connected neural networks for images have two key issues:

CNNs preserve spatial structure and use weight sharing to dramatically reduce parameters.


2. Convolutional Layer

Core Operation

A convolutional layer applies a set of learnable filters (kernels) to the input. Each filter slides spatially over the input and computes dot products.

For a filter of size F×F×CF \times F \times C applied to an input of size W1×H1×CW_1 \times H_1 \times C:

Hyperparameters

A convolutional layer has 4 hyperparameters:

HyperparameterSymbolDescription
Number of filtersKKHow many different filters to learn
Filter sizeFFSpatial size of each filter (e.g., 3×33 \times 3, 5×55 \times 5)
StrideSSStep size when sliding the filter
Zero paddingPPNumber of pixels to pad around the border

Output Size Formula

Given input W1×H1×CW_1 \times H_1 \times C:

W2=W1−F+2PS+1,H2=H1−F+2PS+1W_2 = \frac{W_1 - F + 2P}{S} + 1, \quad H_2 = \frac{H_1 - F + 2P}{S} + 1

The output volume is W2×H2×KW_2 \times H_2 \times K.

Common settings:

Number of Parameters

Each filter has F×F×CF \times F \times C weights plus 1 bias. With KK filters:

Total parameters=K⋅(F2⋅C+1)\text{Total parameters} = K \cdot (F^2 \cdot C + 1)

Example: Input 32×32×332 \times 32 \times 3, K=10K = 10 filters of size 5×55 \times 5, stride 1, pad 2.

Intuition

Each filter learns to detect a specific pattern:

When a patch of the image matches the filter pattern, the dot product yields a large value.


3. Pooling Layer

Pooling reduces spatial dimensions, making representations smaller and more manageable.

Max Pooling

For each 2×22 \times 2 region (typical), output the maximum value.

Common setup: 2×22 \times 2 filters with stride 2, which halves the spatial dimensions.


4. Fully Connected Layer

After several convolutional and pooling layers, the final feature maps are flattened and fed into one or more fully connected layers.


5. Typical CNN Architecture

A CNN is typically a sequence of:

[CONV + ReLU]→[POOL]→[CONV + ReLU]→[POOL]→⋯→[FC]→[Output]\text{[CONV + ReLU]} \rightarrow \text{[POOL]} \rightarrow \text{[CONV + ReLU]} \rightarrow \text{[POOL]} \rightarrow \cdots \rightarrow \text{[FC]} \rightarrow \text{[Output]}

Key properties:


6. Classic Architectures (Overview)

NetworkYearKey Innovation
LeNet1998First successful CNN for digit recognition
AlexNet2012Reinvigorated deep learning with GPU training, ReLU, dropout
VGGNet2014Showed that depth matters; used small 3×33 \times 3 filters exclusively
ResNet2015Introduced skip connections to enable very deep networks