Lesson 10.2 · 9 min read · about 55 min to master at a very slow pace

The Convolution Operation

Slide a small filter over the input, multiply and add at each position: that produces a feature map. A full worked example by hand, what the filter detects, channels, and the output-size formula.

Not startedJump to quiz

The operation

A filter (kernel) is a small grid of learned weights. Place it over a patch of the input, multiply matching values, add them up (plus a bias): that's one output value. Slide it one step and repeat. The grid of outputs is a feature map.

Worked example: 4×4 input, 3×3 filter, stride 1, no padding

Input

1201
0131
2100
1012
∗

Filter (vertical edges)

10-1
10-1
10-1
=

Feature map

02
-1-1

Top-left output: the filter covers the highlighted 3×3 patch. Column sums of the patch are , and ; the filter weights the columns , so the output is .

Top-right: columns 2–4 of the top three rows give sums , so . Bottom row (rows 2–4): and .

This filter responds to a vertical edge: brighter on the left than the right gives a positive value. A CNN learns its filter values; early layers typically end up with edge- and colour-detectors like this one.

Channels

A colour image has 3 channels, so each filter is and sums over all three. A layer with 16 filters produces 16 feature maps, which become 16 input channels for the next layer.

Output size

The standard formula, for input size , filter size , padding and stride :

Here , , , : . Padding adds a border (usually zeros) so the output can keep the input's size; stride is the step between positions. Check your course's notation for these before relying on them in an exam.

A naming detail

Deep learning "convolution" is, strictly, cross-correlation: the filter isn't flipped. Since the filter is learned, the difference doesn't matter in practice.

Stuck? Common doubts

Questions real learners asked while studying this lesson. They stay closed so they don't spoil your own thinking: open only the ones you need.

First passIs the same filter really used at every position?

Yes. That's weight sharing: the 9 weights of a 3×3 filter (times the channels) are the only weights it has, reused at every position. Each different filter in a layer has its own weights and produces its own feature map.

Cheatsheet

Convolution

Slide filter, multiply-add per position (+ bias) → feature map. Output size .

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1calculateInput size 4×4, filter 3×3, stride 1, no padding. What size is the feature map?
Q2calculateA 3×3 patch has column sums 3, 4 and 3 (left to right). The filter weights its columns . What is the output?
Q3calculateInput size 32, filter size 5, padding 2, stride 1. What is the output size?
Q4conceptWhat does the filter with columns respond to most strongly?
Q5conceptA layer has 16 filters applied to a 3-channel image. How many feature maps does it produce?