← Lab

CNN Lab

Convolution · Pooling · Training

Draw an input (12×12)

Drag on the grid to draw. The network classifies whatever is there — including a shape it has never seen.

Architecture

Model stats

1 · Input 12 × 12 × 1
image
A grayscale grid. Every pixel is a number between 0 and 1 — that is all the network ever sees.
2 · Kernels 3 × 3, learned these start random and are changed by training
3 · Feature maps 10 × 10 × K ReLU( convolution + bias )
4 · Max pooling 5 × 5 × K 2×2 window, stride 2 — keeps the strongest response, throws away where exactly it was
5 · Flatten → Dense → Softmax 100 → 3
Draw something, or press Train.

Training

Not trained yet — the kernels are random noise.

Concepts

Convolution

Slide a small 3×3 kernel over the image; at each position multiply overlapping numbers and add them up. One kernel produces one feature map.

z[i][j] = ΣΣ K[a][b]·x[i+a][j+b] + b
Why not a dense layer?

A dense net on 12×12 needs 144 weights per neuron, and learns each position separately. One 3×3 kernel has 9 weights and finds its pattern anywhere in the image.

Max pooling

Take the largest value in each 2×2 block. The map shrinks 4×, and a shape shifted by one pixel still gives nearly the same answer.

p[m][n] = max(a[2m..2m+1][2n..2n+1])
Softmax + cross-entropy

Softmax turns the three scores into probabilities that sum to 1. Cross-entropy loss is small when the right class gets a high probability.

L = −log( p[correct] )
What training changes

Only the numbers inside the kernels, their biases, and the dense weights. Nothing about the image changes — the machine changes.