Lesson 4 of 13 in this unit
Slide a detector across an image.
Reuse one filter at many positions and trace how stride, borders and pooling change the result.
By the end: Compute one convolution response, explain shared weights and receptive fields, and show what pooling loses.
Prerequisites and path options
Why learn this? Understand how shared filters detect patterns across an image without learning a separate rule for every location.
Start with something concrete.
A vertical line can appear on either side of an image. Instead of giving every location a separate detector, slide the same nine weights across it. Predict where right-minus-left will respond positively, negatively or not at all.
Try the interactive modelA 3 × 3 filter visits nine positions. How many weights does this one shared filter use, with no bias?
Change one thing. Watch what follows.
Loading this browser experiment…
Understand what changed.
A shorter explanation, with the original worked examples available below. Both explain the same experiment and its limits.
The idea in everyday terms
A convolutional filter is a small grid of weights reused at different image positions. At each position, multiply the visible pixels by the matching weights and add. Reusing the same filter lets a pattern produce a response in more than one location.
What to watch in the experiment
Follow one window’s arithmetic before inspecting the whole response map. Compare border and center positions, stride and pooling choices. Pooling summarizes nearby responses, which can reduce detail as well as make the representation smaller.
What this does not establish
These synthetic pixel calculations are not a trained image recognizer. Border handling and filter orientation change the result; a strong response does not by itself identify the object or prove useful invariance.
Open the full worked examples, calculations and limitations
This is the same reference used in Technical mode. Expand it whenever you need the exact numbers, assumptions or further explanation.
Start with a small image
A grayscale image can be a grid of brightness values. Our synthetic image has five rows and five columns. A value of 0 is dark and 1 is bright; there are no physical brightness units here. A filter, also called a kernel, is a smaller grid of weights. Place its three-by-three window over the image, multiply each pixel by the matching weight, and add the nine products.
The right-minus-left filter has three identical rows: −1, 0, 1. In the starting image, every row is 0, 0, 1, 0, 0. At the first horizontal position, the three window rows are each 0, 0, 1. Each contributes −1 × 0 + 0 × 0 + 1 × 1 = 1. Three rows give 3. Move one pixel right: each row is 0, 1, 0, giving 0. Move again: each is 1, 0, 0, giving −3. The sign describes the local contrast direction; it is not a class probability.
Try the horizontal-line image with this same filter. Predict the response at a complete interior window. Check why the left and right contributions cancel, then change to bottom-minus-top. A detector’s response depends on both the pattern and its weights.
Reuse a rule, not a result
The output grid is a feature map: one response per visited position. Every position uses the same nine weights. This is weight sharing. Nine positions require 81 multiplications, but still only nine weights. A learned convolutional network adjusts shared weights during training; this lesson uses fixed filters so you can inspect the operation without training.
A receptive field is the set of input positions that can affect a particular output. Here it is a three-by-three window. In a deeper network, a feature can depend on a larger input region through several layers. The highlighted square and product list show this layer’s exact dependencies, including padded positions.
The common neural-network operation is technically cross-correlation: we slide the filter without reversing it. Mathematical convolution flips the kernel. Libraries often call the unflipped operation convolution; this lab follows that convention. There is one input channel, one output channel, no bias and no activation. Real image encoders commonly use several channels and filters.
Decide where the window goes
Stride is the number of pixels the window moves between outputs. A stride of 2 skips some positions. It saves work and reduces output size, but may miss a useful response. It is not the same as evaluating every position and keeping a summary.
Zero padding adds an assumed dark border. With padding 0, only fully fitting windows are evaluated. With padding 1, the window can extend one pixel past each edge. Padded zeros are assumptions, not newly observed pixels. The average filter always divides by nine, even near the border, so a border average includes those assumed zeros.
Here O is output width, N is input width (5), P is padding per side (0 or 1), K is filter width (3), and S is stride (1 or 2). Widths and stride are in pixels. The floor brackets mean round down to a whole number. The same formula applies to height in this square example. It counts all filter placements that fit in the padded image; dilation is not used.
For N = 5, P = 0, K = 3, S = 2, we get floor(2/2) + 1 = 2, so the output is two by two. Practice: keep stride 2 and add padding 1. Predict the width before checking.
Check the width
floor((5 + 2 − 3)/2) + 1 = floor(4/2) + 1 = 3. The output is three by three, with nine placements.
Pooling trades detail for a summary
Pooling takes a block of responses and summarizes it. Max pooling keeps the largest value. Average pooling adds the values and divides by their count. In this lab both use two-by-two blocks with stride 2, no padding, and no activation before pooling. For [−4, −3; −2, −1], max is −1, not zero; average is −2.5. A separate rectified-linear activation would replace negative responses with zero, but we do not apply it here.
Incomplete blocks at the right and bottom are discarded. The workbench reports how many response cells are omitted. Other boundary conventions exist; compare like with like when reproducing an implementation.
Pooling also loses information inside complete blocks. [1, 0; 0, 0] and [0, 0; 0, 1] both have max 1 and average 0.25. These summaries cannot tell which corner was bright. That may be acceptable for “is a bright point present?” and harmful for “which corner contains it?”
Shifts are a testable claim
Reusing a filter lets a translated pattern produce a translated response under suitable conditions. This is equivariance, not a promise that the output stays identical. Finite borders, stride and pooling can break even that relationship. Recognition that stays unchanged under a transformation is invariance, a separate property requiring evidence for the task.
For a guided experiment, compare a dot at a border with a dot in the middle and explain the trace. For implementation, reproduce the map in code, check an asymmetric filter to catch accidental flipping, and test negative pooling inputs. For a decision brief, choose a task where losing location is acceptable and one where it is not. Export the image, settings and explanation as practice evidence. This does not yet supply a trained image model or independently reviewed perception project.
Two different 2 × 2 blocks both produce max 1 and average 0.25. What does that establish?
Take this idea with you.
Convolution shares a local rule across positions. Stride samples locations; padding defines borders; pooling summarizes and loses information.
Explore related topics and the topic map
How this topic connects
Explore this topic on the interactive mapUse these connections to review a foundation or choose where to go next. You can open any topic without completing the others.
What it builds on
- Feature detectors
Inspect which input patterns change a prediction so you can question what an image model has learned.
- Vectors and multiply-and-add
Treat a list of numbers as one representation and trace weighted sums. These operations connect the lesson’s inputs to its outputs.
Reuse one filter at many positions and trace how stride, borders and pooling change the result.
What it enables
- Teach useful invariances
Choose transformations that preserve a task’s answer and avoid augmentations that quietly change it.
- Compare convolution with image attention
Compare local filters and broader interactions when choosing an image representation.