Neural Networks
Convolution / CNN
Change the filter and trace the dot product that builds each cell of the output feature map.
Input · 6×6
Vertical Edge image, Vertical Edge kernel. Output (0, 0), footprint rows 0–2, columns 0–2; raw sum 0. 8 of 16 cells non-zero.
Rows down, columns right, both zero-based. Solid outline: selected 3×3 footprint.
Vertical Edge image, Vertical Edge kernel. Output (0, 0), footprint rows 0–2, columns 0–2; raw sum 0. 8 of 16 cells non-zero.
Input 6×6, kernel 3×3; stride 1, padding 0 (valid), unflipped, no bias or subsequent transformation. All current settings remain active at every stage.
- Input Pixel
- Kernel Window
- Output Cell
Swap the fixed input; signed products can reinforce or cancel.
Where is a pixel in this grid?
To a computer, an image is just a grid of numbers. Switch between the three images and read the pixel values — 36 of them, each one an intensity.
Intensity
One scalar at a zero-based row and column.
Check this stage
Check your understanding
One unflipped kernel computes a signed dot product at each valid input window. Select an output cell and inspect every coordinate, weight and product. This is forward cross-correlation, not training.
What exactly is computed?
Select Image, Kernel Type and Kernel Position. Input is one 6×6 scalar matrix, kernel one 3×3 preset matrix and output 4×4. Indices are zero-based [row, column], rows down and columns right. Inspect output cell and the position range select the same calculation.
The solid outline covers the selected input footprint. Nine tiles connect each printed kernel coordinate to its sampled input coordinate. From The Dot Product they show pixel × weight = signed product. The dashed output outline identifies the resulting cell. The whole map computes immediately; moving the window inspects it.
This is cross-correlation: top-left multiplies top-left, with no kernel flip. Mathematical convolution flips both axes. Image Kernels has an operation control; this lab keeps the operation fixed.
Stride is one on both axes, padding zero (valid), dilation one. No padded coordinates are sampled or border values supplied. There is one scalar plane and one filter, no batch/channel axes or channel reduction. No bias, activation, pooling, loss, derivative or optimiser is applied. Final output equals the raw linear filtering sum. Presets are manually selected, not learned here.
Follow one signed sum
Keep Vertical Edge for input and kernel; select (0,1). Each input row covers columns 1,2,3: [0,0,1]. Each kernel row is [−1,0,1]. Each contributes 0×(−1) + 0×0 + 1×1 = 1. Three rows sum to 3, without bias. Flipping this asymmetric kernel gives −3 on the same patch, making orientation independently testable.
Sharpen gives [0, −1, 2, 1] in each default output row: linear filtering can produce negatives and exceed the input range. Box Blur uses nine weights of 1/9, giving [0, 1/3, 2/3, 1] up to double rounding. Nine unit weights sum instead of averaging. Identity returns input centres at rows/columns 1 through 4, cropping the border.
A large response is a large weighted sum, not proof of useful task information. Familiar hand-written edge filters do not prove every learned filter detects edges or every CNN forms the same hierarchy.
Why can a map be entirely zero?
At The Feature Map, choose Horizontal Edge on Vertical Edge input, or Load cancellation. Top and bottom rows are identical at every window, so signed terms cancel. The transposed mismatched pair also gives exactly zero at all sixteen cells. The challenge keeps this exact condition.
Zero does not prove absence of edges or information. Three repeated [0,1,0] rows vary yet cancel under the vertical kernel. On a constant patch a, the exact-arithmetic response is a times the kernel sum. Zero weights give zero on finite input, without implying every possible training gradient is zero.
Cells Firing counts values unequal to exact numerical zero; it is not an activation or usefulness threshold. Negative responses count too. Cancellation, zero inputs/weights, display rounding and floating-point underflow are different reasons a display might look zero. Raw doubles remain in inspection; nonfinite arithmetic is not successful cancellation.
Why is the output smaller?
Valid starts are rows 0,1,2,3 and columns 0,1,2,3. Start 4 needs coordinate 6, outside input 0..5. Four starts per axis give sixteen windows.
For a separate dilation-one operation with symmetric padding p and stride s:
Here n=6, k=3, p=0, s=1 give 4. At hypothetical stride two only starts 0 and 2 fit: floor(3/2)+1=2. Remaining extent is discarded; no partial window computes. These examples are not controls here. Image Kernels explores stride and explicit borders.
Zero padding supplies assumptions outside the image and can create boundary responses on constant inputs. One border per side preserves size for a 3×3 kernel at stride one; this does not hold unchanged for arbitrary stride/dilation. Replication and reflection differ, and neither is used here.
What is shared, and what is local?
The same nine coefficients appear at every location. Fix 36 inputs, sixteen outputs and the 3×3 footprint, excluding biases: 9 shared weights, 144 independent local weights, 576 dense weights. Fewer Weights compares dense to shared: 64×.
Shared and independently weighted local calculations both use 144 scalar products in a straightforward forward pass. Parameter count differs from computational cost. Sharing/locality constrain the function family; they do not prove optimisation success or generalisation. No models are trained or compared for accuracy here.
Each output has a 3×3 theoretical receptive field. Two composed undilated stride-one 3×3 layers can cover a 5×5 interior region of the original input; that network is not simulated here. Zero coefficients can remove actual dependencies within a theoretical footprint.
Sharing supports translation equivariance: shifts give corresponding shifted responses where the same windows remain valid, fixing kernel values/orientation, stride, border convention, bias and subsequent operations. It does not leave the map unchanged, which would be invariance. Boundaries/cropping restrict correspondence. Larger strides preserve only compatible sampling-grid shifts and can alias others. Pooling may preserve a window maximum under some movements, without guaranteeing global invariance. No pooling is computed here.
Read the display without changing the operation
Input fill is neutral. Signed weights/products/outputs retain printed signs. Map fill uses |value| divided by that matrix's maximum absolute value, mapped through the shared nonzero opacity floor/ceiling. Zero maps avoid division. Separately scaled maps do not share an absolute brightness scale. No interpolation, clipping or absolute-value replacement changes raw responses.
Grid labels round to zero or two decimal places and are omitted in small cells; tiles round to relevant matrix precision. Inspection retains every full input, weight, product and output. Rounded zero does not mean exact zero.
Keep and share the experiment
Earlier stages retain settings. Explore freely unlocks all controls. Selection and image/kernel/stage/mode edits clear predictions. Load cancellation saves the whole preceding state; Restore experiment returns its original stage, presets, selection, sandbox and prediction even after later edits. Recovery stays reachable in sandbox and earlier stages.
Reset controls retains guided stage, defaults presets/selection, returns guided and clears guesses/recovery. URL navigation also clears them. Share reproduces presets, selected cell and displayed stage in guided mode by recomputation. Fixed shapes have no inactive matrix values to discard. Guesses, recovery and sandbox identity stay in memory; Mark explored stores local exploration without grading answers.
Sources and the next question
Deep Learning chapter 9 distinguishes sharing and equivariance. Dive into Deep Learning explains products and padding/stride arithmetic. PyTorch Conv2d documents the unflipped convention; its extra parameters are not this lab's capabilities. LeCun and colleagues study trained networks, a different experiment.
For boundary assumptions and editable kernels use Image Kernels. For separate aggregation use Pooling. Neither is silently appended to this output.
Stage recap
The Input
To a computer, an image is just a grid of numbers. Switch between the three images and read the pixel values — 36 of them, each one an intensity.
The Kernel
A kernel is a smaller grid of weights, shown here beside the image. It sits over a 3x3 patch at a time, and there are only 16 places a 3x3 window fits on a 6x6 image.
The Dot Product
At each position, multiply the nine pixels under the window by the nine kernel weights and add the results. That single sum is the whole operation.
The Feature Map
Each sum becomes one cell of the feature map on the right. Change the kernel or the image and watch how many cells respond at all.
Weight Sharing
The same nine weights produced all 16 cells — they never change as the window moves. A fully connected layer wiring 36 pixels to 16 outputs would need 576.
Reference
- Kernel (Filter)
- Manually selected coefficients; not learned in this lab
- Stride
- How many pixels the kernel moves at each step (here, 1)
- Padding
- Adding pixels to the border to control output size (here, valid/none)
- Feature Map
- The output image produced by the convolution
- Dot Product
- Element-wise multiplication followed by a sum
- Weight Sharing
- One kernel reused at every position: 9 weights here, against 6x6 x 4x4 = 576 for a dense layer of the same shape
- Cross-correlation
- This lab and PyTorch Conv2d use unflipped cross-correlation. Mathematical convolution flips both kernel axes.
Break it on purpose
Horizontal Edge on the Vertical Edge image, or the transposed pair, makes all 16 cells read exactly 0 by signed cancellation. A zero response does not prove an absence of variation.
Explore next
- Image KernelsEach output cell is the sum of the nine pixel–weight products under its window.
- Pooling (Max & Average)Shift an input feature and trace how crossing a pooling window changes the output.
- BackpropagationMultiply local Jacobians along each path; add contributions where a value feeds multiple paths.