Calculating a Convolution
Calculate one convolution output through multiplication and addition.
Calculating a Convolution explained visually
Follow a three-by-three image region through one complete filter calculation.
What you will learn
Follow filters, pooling, flattening, and classification through complete CNN examples.
IMAGE REGION
Place the three-by-three filter directly over a matching image region.
FILTER ALIGNMENT
Multiply every image value by the filter value in the same position.
MULTIPLY PAIRS
Add the nine products, then include a bias when the layer uses one.
ADD PRODUCTS
Move the filter and repeat the calculation to construct the output feature map.
Quick check: test your understanding
How many products come from a three-by-three filter?
Nine.
What happens after multiplication?
The products are added together.
How is a feature map created?
The filter moves and repeats the calculation at new positions.
Accessible referenceLesson 46 transcript290 words · Matches the published narration and captionsOpen transcript
Let us calculate a simple convolution. Imagine a three-by-three image region containing these values: One, two, and zero in the first row. Zero, one, and two in the second row. Two, zero, and one in the third row. Now imagine a three-by-three filter containing: One, zero, and negative one in each row.
We place the filter directly over the image region. The first step is element-by-element multiplication. In the first row, we calculate one times one, two times zero, and zero times negative one. That gives one, zero, and zero. In the second row, we calculate zero times one, one times zero, and two times negative one.
That gives zero, zero, and negative two. In the third row, we calculate two times one, zero times zero, and one times negative one. That gives two, zero, and negative one. We then add all nine results. One plus zero plus zero, plus zero plus zero minus two, plus two plus zero minus one, produces zero.
The output for this filter position is therefore zero. The filter then moves to the next valid position and repeats the same calculation with a different image region. Each position produces one value in the output feature map. In a real CNN, the inputs may represent image pixels or activations from an earlier layer.
The filter values may include decimal numbers learned during training. A bias can also be added before the activation function processes the result. The calculation remains the same: multiply corresponding values, add the products, add the bias when present, and produce an activation. This repeated local calculation allows the network to search an entire image for one learned pattern. In the next lesson, we will examine the complete output created by this process.