Convolutional Neural Networks

convolution kernel

A convolution kernel is the small grid of learnable weights that defines what one filter is looking for. It is the 'stencil' that slides over the input. Think of it as a tiny template of a local pattern: when the patch of input under the kernel resembles the kernel's pattern, the weighted sum is large; when it does not, the sum is small. Training adjusts these weights so that, over millions of examples, each kernel sharpens into a useful detector — an edge at a certain angle, a blob of a certain color, a small texture.

Precisely, a kernel in a 2D convolutional layer is a 3D tensor of shape (C_in, k, k): it has a height and width of k (the spatial window, commonly 3x3, 5x5, 7x7, or 1x1) and a depth equal to the number of input channels C_in. It therefore contains C_in times k times k learnable numbers, plus one shared bias. A layer with C_out output channels holds C_out such kernels stacked together, often written as a 4D weight tensor of shape (C_out, C_in, k, k). The word 'filter' is usually used as a synonym for 'kernel', though some authors reserve 'kernel' for the per-channel 2D slice and 'filter' for the full 3D stack across channels.

Kernel size trades expressiveness against cost and receptive field. Large kernels (7x7) see a wide neighbourhood at once but are expensive and parameter-heavy; small kernels (3x3) are cheap, and stacking two 3x3 layers reaches the same 5x5 receptive field with fewer parameters and an extra nonlinearity in between — the insight that made VGG's all-3x3 design dominant. The extreme case, a 1x1 kernel, sees no spatial neighbourhood at all and instead mixes information across channels.

Common confusion: 'kernel' here is unrelated to the kernel in kernel methods / SVMs (a similarity function) or the OS kernel. In CNNs it is just the learnable filter weights. Also note the kernel always extends through the full input depth — there is no such thing as a 3x3 kernel that ignores some input channels in a standard convolution.

Also called
filterweight tensor