A convolution finds edges. A pooling layer shrinks the result. Neither one, by itself, produces a decision. A real network chains several of these together, then hands the result to a plain layer that actually decides.
This image has a light-dark-light stripe. The kernel from Chapter 1 convolves it, ReLU — short for Rectified Linear Unit — keeps only the positive (dark-to-light) evidence, pooling shrinks the result to 4 numbers, and a small dense layer turns those 4 numbers into a decision: edge detected. Five stages, one pipeline, no step done by hand — every one of them just a repeated small computation.
A minimal CNN chains exactly the pieces built so far, plus one new one:
- conv — the convolution step from Chapter 1: sliding the learned kernel across the image.
- ReLU — the rectified-linear activation, , applied elementwise right after the convolution.
- pool — the max-pooling step from Chapter 2: shrinking the feature map by keeping only the strongest response in each window.
- flatten — reshaping the small 2D map into a single 1D vector.
- dense — the fully-connected layer from Part III that turns the vector into logits.
- What ReLU computes
ReLU is the one piece not yet introduced: , applied to every value independently, right after the convolution.
- Why it's there
It's what turns "how strongly does this patch match the filter, in either direction" into "how strongly does this patch match, and only when the match actually supports the feature."
Toggle ReLU off. The raw feature map has both a (a dark-to-light transition — evidence for the filter's direction) and a (a light-to-dark transition — evidence against it). Pooling keeps both, flattening gives , and the dense layer's two votes nearly cancel to and — the wrong class wins. Turn ReLU back on: the s become , flattening gives , and the votes come out and — a clean, correct decision.
- With ReLU on
The pooled map flattens to . The "edge detected" neuron has weights and bias : . The "no edge" neuron has weights and bias : . Since , the network predicts "edge detected" — correctly.
- Without ReLU
The same two neurons see instead: and , so flips the decision to "no edge" — wrong, because the genuine positive evidence got cancelled by evidence that ReLU exists specifically to discard.
Set ReLU so the network predicts the true class, “Edge detected”.
Every weight in this pipeline — the kernel, the dense weights, the biases — was hand-picked here. A real network learns all of them from data, the same backprop as always, just with a convolution and a pooling layer added to the chain of derivatives. The next chapter does exactly that: trains this shape of network on real digit images, live, and shows what its filters end up learning to detect.