ML//CNN//convolution
A convolution is a neural network operation that applies the same learned kernel at every spatial position, producing a local weighted sum, and it is the building block that lets CNNs find patterns in images wherever they appear. Small kernels can compose edges and textures into progressively larger receptive fields. In one dimension it is exactly the sliding sum of a FIR filter:
A convolution is a neural network operation that applies the same learned kernel at every spatial position, producing a local weighted sum, and it is the building block that lets CNNs find patterns in images wherever they appear. Small kernels can compose edges and textures into progressively larger receptive fields. In one dimension it is exactly the sliding sum of a FIR filter:
y[n]=∑m=0M−1w[m] x[n−m]+by[n]=\sum_{m=0}^{M-1}w[m]\,x[n-m]+by[n]=m=0∑M−1w[m]x[n−m]+b
Here xxx is the input signal, www the MMM coefficients of the kernel, bbb a bias and yyy the output; in a CNN the coefficients are learned by backpropagation instead of designed. What deep learning libraries compute is technically a correlation (the kernel is not flipped), which changes nothing since the kernel is learned either way. In 2D a 3 by 3 kernel sweeps the image, and a layer applies many kernels in parallel, its channels: 64 kernels give 64 feature maps, each tuned to a different pattern.
Weight sharing makes the operation translation equivariant: shifting the input shifts the feature map. Invariance requires an additional mechanism such as pooling, aggregation, or training augmentation.
The kernel encodes locality as an architectural prior (inductive bias). This makes CNNs data-efficient for images, but less natural when every location must interact globally from the first layer.
The parameter count depends on the kernel and the channels only: 3⋅3⋅64⋅64+64=36,9283\cdot3\cdot64\cdot64+64=36{,}9283⋅3⋅64⋅64+64=36,928 for a 3 by 3 layer from 64 to 64 channels, at any image size (weight sharing).
Padding, stride, and boundary handling belong to the design as much as the kernel: they determine which spatial information survives and how coordinates leak into the representation.