Convolution kernel

Also known as: convolution filter

On this page 7

A convolution kernel, also called a convolution filter, is a small tensor of learnable weights that a convolutional layer slides across its input, computing a weighted sum at every position to produce one channel of a feature map. In neural networks, kernels are the basic pattern detectors of the convolutional neural network: early kernels respond to edges and color contrasts, while deeper kernels respond to textures, parts and whole objects.

Unlike the fixed filters of classical image processing, such as a Sobel or Gaussian filter, the values of a kernel in deep learning are learned by backpropagation. The same kernel is applied at every location, a principle called weight sharing, which gives convolution its efficiency and its tolerance to shifts in position.

How a convolution kernel computes a feature map

At each position, the kernel is aligned with a patch of the input, each kernel weight is multiplied by the input value beneath it, and the products are summed together with a bias term. The result becomes one output value. Moving the kernel by the stride and repeating the operation fills a two-dimensional output grid.

Strictly speaking, most deep learning libraries implement cross-correlation, because they do not flip the kernel before sliding it. Since the weights are learned, the distinction has no practical effect on what a network can represent, and the operation is still called convolution.

For a color image, a kernel spans all input channels. A 3 by 3 kernel over an RGB input therefore has a shape of 3 by 3 by 3, or 27 weights plus one bias. A layer with 64 kernels produces 64 output channels, one per kernel, and each output channel is then usually passed through an activation function such as ReLU.

Kernel parameters and their effects

Several hyperparameters control how a kernel interacts with its input. The table summarizes the most important ones and their typical values in modern architectures.

ParameterTypical valuesEffect on the output
Kernel size1×1, 3×3, 5×5, 7×7Larger sizes see more context per step
Stride1 or 2Stride 2 halves the spatial resolution
PaddingSame or validSame padding preserves height and width
Dilation1, 2, 4 or moreSpreads taps apart to widen coverage
Groups1 up to channel countSplits channels into independent groups
Number of kernels32 to 2,048Sets the number of output channels
Main kernel hyperparameters

The output spatial size follows a simple rule: (input + 2 x padding – dilation x (kernel – 1) – 1) / stride + 1, rounded down. Errors in this calculation are a frequent source of shape mismatches when layers are stacked by hand.

Types of convolution kernels

Architectures use several kernel variants to balance accuracy, parameter count and computation. Each variant changes which input values a single kernel combines.

Kernel typeWhat it combinesTypical use
Standard 2D kernelSpatial neighborhood across all channelsGeneral image feature extraction
1×1 kernelChannels at a single positionMixing or reducing channel count
Depthwise kernelSpatial neighborhood within one channelMobileNet-style efficient networks
Dilated kernelSpaced-out neighborhoodSemantic segmentation, audio models
Transposed kernelSpreads each input value to a larger areaUpsampling in decoders and U-Net
1D and 3D kernelsSequences or volumes and videoAudio, text, medical scans
Common kernel variants

A depthwise separable convolution pairs a depthwise kernel with a 1×1 kernel. For a 3×3 layer with many channels, this cuts multiply operations by roughly eight to nine times compared with a standard convolution, at a modest cost in accuracy.

Kernels, receptive fields and parameter efficiency

A single kernel sees only a small window, but stacking layers enlarges the receptive field, the region of the original input that influences one output value. Two stacked 3×3 kernels cover a 5×5 region, and three cover a 7×7 region, while using fewer parameters and more nonlinearities than a single large kernel. This insight shaped VGG and later ResNet designs.

The comparison below shows why weight sharing matters. It contrasts a convolutional layer with a fully connected layer on the same 224 by 224 RGB input producing 64 output channels or units.

Layer typeWeights per output unitTotal parametersPosition awareness
3×3 convolution, 64 kernels27About 1,800Translation equivariant
7×7 convolution, 64 kernels147About 9,500Translation equivariant
Fully connected, 64 units150,528About 9.6 millionNone built in
Parameter count for the same input

Translation equivariance means that shifting the input shifts the feature map by the same amount. Combined with a pooling layer or strided convolution, it gives networks partial tolerance to small shifts, although full invariance is not guaranteed.

Practical issues and common mistakes

Kernels are simple, but their configuration has real consequences for accuracy, memory and speed. The most frequent problems and their remedies are summarized here.

SymptomLikely causeFix
Checkerboard artifacts in outputsTransposed kernel overlapResize then apply a regular convolution
Gridding artifactsSame dilation in every layerVary dilation rates across layers
Training stalls earlyPoor weight initializationUse He initialization with ReLU
Edges of images degradeZero padding effectsTry reflection padding or crop margins
Slow inference on mobileLarge dense kernelsSwitch to depthwise separable kernels
Symptoms, causes and fixes

A further misconception is that every learned kernel has a clean visual meaning. First-layer kernels often resemble edge and color detectors, but deeper kernels respond to distributed combinations of features and are best studied through their activations, not by viewing their raw weights.

The idea in brief

A convolution kernel is a tiny pattern detector. Imagine a small stencil that you slide over a photo, square by square. At each spot, the stencil gives a high score if the patch underneath matches its pattern, such as a vertical edge, and a low score otherwise.

A neural network uses hundreds of these stencils and learns their patterns from examples instead of having people design them. Simple stencils find lines and corners, and later layers combine those findings into eyes, wheels or letters.

A practical scenario

A manufacturing quality team trains a convolutional network to spot scratches on brushed metal panels photographed at 1,024 by 1,024 pixels. Their first design uses 7×7 kernels in every layer and runs too slowly on the inspection line’s edge device, which must judge each panel in under 50 milliseconds.

The engineers replace each large kernel with stacks of 3×3 kernels and convert most layers to depthwise separable convolutions. The receptive field stays wide enough to see scratches several centimeters long, while the parameter count falls sharply. Because hairline scratches cluster near panel borders, they also switch to reflection padding. The redesigned model meets the latency target and misses fewer edge defects than the original version on the team’s validation set.