CNN Convolution Activity

A hands-on route from sliding weighted neighborhoods to output shapes, stride, padding, filter count, and pooling.

1 Filter placement creates one feature-map value.
2 Shape is controlled by filter size, padding, stride, and pooling.

From 1D Speed Readings To 2D Feature Maps

A cricket speed gun captures a short burst of rapid readings for each ball. A 3-reading weighted window slides over that burst, and the same sliding-window idea then extends to 2D neighborhoods.

1D Convolution: Cricket Speed Gun

Each delivery has five quick readings. A 3-reading window slides across them, giving the newest reading in the window the largest weight.

Rapid readings for this ball

Ball 1
y[j] = w1*r[j] + w2*r[j+1] + w3*r[j+2]
ball 1 = 0

Weighted window

early to recent

Sliding outputs

3 window outputs

What Filters Are Trying To Do

The same original image can be transformed in different ways depending on the filter weights. In CNNs, these useful filters are learned from data instead of hand-picked.

Broad idea

A filter is a small pattern detector or image operator that is reused across the whole image.

Original source

No filter applied

A small practice-net scene with edges, texture, and smooth regions. The three filters below all start from this same image.

Blur smooth

1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9
Each neighbor contributes equally.

Reduces small noisy changes and softens detail. Useful before later processing when tiny variations should not dominate.

Edge detector boundary

-1 -1 -1 -1 8 -1 -1 -1 -1
Center is compared against neighbors.

Highlights where brightness changes sharply. Useful for locating outlines such as the ball, bat, crease, or object boundaries.

Sharpen detail

0 -1 0 -1 5 -1 0 -1 0
Center is boosted, close neighbors subtract.

Boosts local contrast so details look crisper. Useful when boundaries and fine texture need to stand out more strongly.

Input field

6 x 6 readings

Filter

3 x 3

Feature map

4 x 4
sum = 0

Shape Lab: Build The Formula Step By Step

Walk through the lecture sequence: normal filter shrinkage, stride, padding and floor, depth from K filters, then pooling.

Step 1

Normal filter: output shrinks at the boundary

With stride 1 and no padding, the filter cannot start where it would fall outside the input.

Filter-only output 4 x 4

Filter-only rule

W2 = H2 = N - F + 1

A 3 x 3 filter loses one border cell on every side, so 6 becomes 4.

Input

6 x 6

Output starts

4 x 4
Step 2

Stride: take larger steps between starts

Stride does not change the filter. It changes how many legal starts you actually visit.

Stride output 2 x 2

Stride intuition

W2 = H2 = floor((N - F) / S) + 1

Stride 2 roughly halves the number of starts. Floor keeps only full filter placements.

Visited starts

S = 2

Stride output

2 x 2
Step 3

Padding: add a border before filtering

Padding gives boundary cells enough artificial neighbors, then stride and floor decide the final count.

With padding 3 x 3

Full spatial rule

W2 = H2 = floor((N + 2P - F) / S) + 1

Padding adds P cells on every side, so the width gains 2P before filtering.

Padded input

8 x 8
Input Padding Current start

Full-rule output

3 x 3
Step 4

3D input still uses 2D sliding

A filter spans the full input depth, slides across width and height, and produces one 2D feature map. K filters produce depth K.

Output volume 3 x 3 x 4

Depth rule

D2 = K

Each filter has F x F x D1 weights.

Input volume

6 x 6 x 3
3 x 3 x 3 filter
slide only width and height

Feature maps

K maps
Step 5

Pooling: shrink each feature map without weights

Pooling works per feature map. Max pooling keeps the strongest local response; average pooling keeps the local mean.

After pooling 1 x 1 x 4

Pooling rule

P2 = floor((N2 - R) / S_pool) + 1

Pooling has 0 learned parameters and keeps depth K.

One feature map

3 x 3

Pooled map

1 x 1