Multimedia & Machine Learning Algorithms · Multimedia Algorithms
Convolutional Neural Networks (CNN) for Image Processing
Explanation
Intuition: Why CNN?
A standard MLP treats every pixel independently — it doesn't know that neighboring pixels are related. A CNN exploits the spatial structure of images through two key principles:
- Parameter sharing: the same kernel (filter) slides over every region — one set of weights for all positions.
- Translation equivariance: if the edge moves left, the output feature map shifts left too.
Cross-Correlation — Not True Convolution!
What CNNs call "convolution" is actually cross-correlation: the kernel slides over the input without flipping:
True mathematical convolution does flip the kernel 180°, using . In CNNs the kernel is learned — a 180° rotation only affects initialization, and the network adjusts regardless.
Output Size
For input , kernel , padding , stride :
Example: .
"Same" padding: — keeps output the same size as input (for and odd kernel size ; with the output shrinks even with this padding).
Parameter Count
A convolutional layer with filters, kernels, input channels, with bias:
Max Pooling
Divides the feature map into windows and takes the max from each. Reduces dimensions and grants robustness to small spatial shifts:
Receptive Field
The receptive field of a neuron after layers with kernels and stride=1:
Example: 3 layers of — .
Batch Normalization
For each mini-batch, BatchNorm normalizes activations before the nonlinearity:
where , , and are learnable. BatchNorm improves gradient flow and allows higher learning rates.
A standard MLP treats every pixel independently — it doesn't know that neighboring pixels are related. A CNN exploits the spatial structure of images through two key principles:
- Parameter sharing: the same kernel (filter) slides over every region — one set of weights for all positions.
- Translation equivariance: if the edge moves left, the output feature map shifts left too.
Cross-Correlation — Not True Convolution!
What CNNs call "convolution" is actually cross-correlation: the kernel slides over the input without flipping:
True mathematical convolution does flip the kernel 180°, using . In CNNs the kernel is learned — a 180° rotation only affects initialization, and the network adjusts regardless.
Output Size
For input , kernel , padding , stride :
Example: .
"Same" padding: — keeps output the same size as input (for and odd kernel size ; with the output shrinks even with this padding).
Parameter Count
A convolutional layer with filters, kernels, input channels, with bias:
Max Pooling
Divides the feature map into windows and takes the max from each. Reduces dimensions and grants robustness to small spatial shifts:
Receptive Field
The receptive field of a neuron after layers with kernels and stride=1:
Example: 3 layers of — .
Batch Normalization
For each mini-batch, BatchNorm normalizes activations before the nonlinearity:
where , , and are learnable. BatchNorm improves gradient flow and allows higher learning rates.
Interactive Visualization
Loading visualization
Worked Examples
Practice
Exercise 1 of 6
1
A convolutional layer receives a input, kernel, padding , stride . What is the output size (number of rows/cols)?
★Quiz
Test your knowledge from this lesson
A mix of questions from the lesson — each attempt varies slightly
Answer at least 4 out of 5 questions correctly to pass (70%)