Kernel (Filter)
A kernel, also called a filter, is a small grid of learnable numbers that slides across an input and looks for a particular local pattern. Early in training it has no special meaning; through learning, it becomes sensitive to useful structures such as edges, textures, transitions, or more abstract combinations of features.
How a kernel produces a feature mapFor each position, the convolution layer multiplies the kernel’s values by the values in the matching input patch, then adds the results and a bias. That single number records how strongly the patch matches what the kernel has learned. Repeating this across every valid position produces a feature map. Deep-learning libraries usually perform cross-correlation rather than mathematically flipping the kernel first, but the layer is still called a convolution.
- A 3×3 kernel inspects nine nearby positions at once.
- With multi-channel input, such as an RGB image or prior feature maps, each kernel has weights for every input channel.
- One kernel produces one output channel; a layer with 64 kernels produces 64 feature maps.
During backpropagation, the loss gradient adjusts every kernel weight. A weight is strengthened when the corresponding input pattern helps reduce error and weakened when it does not. Because the same kernel is reused at every location—weight sharing—a pattern learned in one place can be detected elsewhere. This gives convolutional layers far fewer parameters than fully connected layers and makes them practical for large grids. In PyTorch, torch.nn.Conv2d stores these learned filters.
Design choices and training consequencesKernel size controls the local view: small 3×3 filters are cheap and can be stacked to build a wider receptive field, while larger filters cost more computation and parameters. Stride determines how far a filter moves, and padding controls whether border information is preserved. Too much stride can discard fine detail; no padding shrinks feature maps at every layer. A convolution layer with too few filters can bottleneck the model, while many large filters raise memory use and can overfit. In a ResNet block, several small kernels plus a skip connection let the network refine features without forcing each layer to rediscover the input.
A kernel or filter is a small, learnable array of weights slid across an input to compute local weighted sums. Each kernel detects a particular spatial pattern and produces one output feature map; a convolutional layer learns many kernels to extract multiple features. Kernels matter because local connectivity and shared weights capture structure efficiently while greatly reducing parameters compared with fully connected layers.
Think of a kernel, also called a filter, as a tiny pattern-spotting window that slides across an image. One filter might become good at noticing horizontal edges, like the rim of a table. Another may spot curves, corners, or small patches of colour.
As the network looks at many examples, it learns which patterns are useful. Early filters notice simple details; later parts of the network combine those details into larger ideas, such as eyes, wheels, or faces. Using the same small filter across the whole image helps the network recognize a pattern wherever it appears.