Convolutional Neural Networks
Convolutional neural networks exploit spatial structure via convolution and pooling. They are the dominant architecture for image and video processing.
Key Points
- Convolution applies a learned filter locally across the input.
- Weight sharing reduces parameters and encodes translation equivariance.
- Pooling provides local translation invariance and downsampling.
Formulas
2D convolution
$$(I * K)(i,j) = \sum_m \sum_n I(i+m, j+n) K(m,n)$$
Backprop through convolution
$$\frac{\partial L}{\partial K} = I * \frac{\partial L}{\partial O}$$
Code Example
import torch.nn as nn
conv = nn.Conv2d(in_channels=3, out_channels=16, kernel_size=3, padding=1)
pool = nn.MaxPool2d(kernel_size=2)
out = pool(conv(image_tensor))