A convolution kernel is a learned matrix of weights that slides across local regions of an input, multiplies corresponding values, and sums them to produce a feature map. Shared weights let one kernel detect the same pattern at different positions, such as an edge or texture. section 4.2.1 section 4.2
Unlike a fully connected layer, a convolution kernel sees a small input region rather than every input value. This local connectivity reduces parameters and supports efficient image processing. Convolutional layers extract features; transposed convolutional layers instead upsample or generate higher-resolution feature maps. section 4.2 section 4.2
The main convolution settings determine how the kernel interacts with the input:
- in_channels identifies the input channels: 1 for grayscale and 3 for RGB images. section 4.2.1
- out_channels sets how many output feature channels, and therefore learned feature detectors, the layer produces. section 4.2.1
- kernel_size controls the kernel dimensions, such as 2 × 2, 3 × 3, or 4 × 4. section 4.2.1
- stride controls the movement between scanned positions, while zero-padding controls how borders participate in the operation. section 4.2
A 2 × 2 kernel in PyTorch
Represent a 3 × 3 grayscale image with shape (1, 1, 3, 3), then create nn.Conv2d(in_channels=1, out_channels=1, kernel_size=2, stride=1). Replace its weights with [[1, 2], [3, 4]] and its bias with 0. Applying the layer produces a 2 × 2 feature map: [[7, 14], [54, 50]]. Each value comes from element-wise multiplication over one local 2 × 2 region followed by summation.










