tezvyn:

How a convolutional layer works

AI-drafted, machine-checkedSource: interviewbeginner
WHAT IT TESTS

the mechanics of convolution.

OUTLINE

learnable kernels slide over the input computing dot products, with stride controlling step size and padding controlling output size.

WHAT THIS TESTS Whether you understand the actual computation inside a conv layer, not just that it detects features. This is foundational for everything in deep vision.

A GOOD ANSWER COVERS A convolutional layer has a stack of learnable filters called kernels, for example a kernel of size three by three by C where C is the input channel count. Each kernel slides across the input's spatial dimensions; at every position it performs an element-wise multiplication with the underlying patch and sums the result, technically a cross-correlation, producing a single scalar. Doing this across all positions yields one two dimensional feature map per kernel, and stacking the maps from all kernels gives the output volume whose depth equals the number of kernels. Stride controls how many pixels the kernel jumps each step, with larger strides downsampling the output. Padding adds zeros around the border so the output can keep the input's spatial size. A bias is added and a nonlinearity applied afterward.

COMMON WRONG ANSWERS Describing it like a dense layer where every input connects to every output; conv uses local connectivity and shared weights. Forgetting that each kernel spans the full input depth. Saying convolution and cross-correlation are mathematically identical in implementation; frameworks use cross-correlation.

LIKELY FOLLOW-UPS How do you compute output spatial size from input, kernel, stride, and padding. Why does weight sharing reduce parameters. What is the difference between valid and same padding.

ONE CONCRETE EXAMPLE An RGB input of thirty-two by thirty-two by three convolved with ten kernels of size three by three by three, stride one, padding one, produces a thirty-two by thirty-two by ten output. Each output pixel is a dot product over twenty-seven input values plus a bias, and the same twenty-seven weights are reused at every spatial location, which is why a conv layer has far fewer parameters than a dense layer of comparable size.

Read the original → en.wikipedia.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.