Convolution as a Sliding Window
What you'll learn: You'll understand how convolution physically works by sliding a filter across an input to extract features.
The Core Idea
In the previous lesson, you learned convolution's mathematical definition. Now let's visualize how it actually happens: as a sliding window operation.
Imagine you have a small magnifying glass (the filter/kernel) that you systematically move across a large photograph (the input). At each position, you:
- Look at what's under the glass (the receptive field)
- Perform element-wise multiplication between the filter and that region
- Sum up all those products to get a single output value
- Shift the magnifying glass and repeat
This "slide, compute, shift" process is the heart of convolution.
How the Window Slides
The filter starts at the top-left corner of your input. You compute the dot product between the filter weights and the corresponding input values. This produces one number in your output (feature map).
Then you slide the filter one step to the right (controlled by stride) and repeat. When you reach the right edge, you move down one row and start again from the left. You continue until you've covered the entire input.
Why this matters: This sliding window approach means the same filter weights are reused across the entire input. This creates two powerful properties:
- Parameter sharing: Fewer parameters to learn
- Translation invariance: The filter detects the same pattern regardless of where it appears in the input
Key Differences from Dense Layers
Unlike fully-connected layers that connect every input to every output, convolution only looks at local regions through this sliding window, making it efficient and spatially aware.
Key Takeaway: Convolution operates by sliding a small filter across the input like a moving window, computing local features at each position and creating a spatial feature map.