Start with a fully-connected layer: every output unit yp=∑qWpqxq+bp. For a
100×100 image feeding a 100×100 hidden layer, that is 108 weights. Two problems:
No spatial prior — pixel (0,0) and (99,99) get independent weights, so the net cannot
"know" that nearby pixels matter more.
No reuse — a feature learned at one location must be re-learned everywhere.
Impose two constraints on W:
Locality: Wpq=0 unless q is in a small k×k neighbourhood of p.
Weight sharing: the samek2 weights are used for every output p.
Substituting these constraints into yp=∑qWpqxq collapses the giant matrix into a single
tiny kernel K slid across the image — and out pops the convolution formula above. Convolution is
just a constrained fully-connected layer. That is the WHY.
Real images have C channels (RGB, or stacked physics fields). A filter is then k×k×C;
you sum over channels too. With F filters the output has F channels. Parameters=F(k2C+1).
Max keeps the strongest "feature present?" signal; average smooths/retains overall magnitude.
Recall Feynman: explain to a 12-year-old
Imagine you have a tiny stamp with a pattern on it, and a big sheet of stickers. You press the same
stamp all over the sheet and mark wherever the pattern matches — that stamping is convolution,
and using one stamp everywhere means you don't need to memorise a different rule for every spot.
Then you look at the marked sheet in little 2×2 squares and, in each square, keep only the
loudest mark — that's max-pooling. Now the sheet is smaller and you still remember where kinds
of things are, even if they wobbled a little. Stack many stamps and shrinks, and the computer
learns to recognise cracks in a wing or runways from the sky.
Dekho, CNN ka core idea bahut simple hai: ek chhota sa filter (kernel) lo, usse poori image ke
upar slide karo, aur har jagah same weights use karo. Isko convolution kehte hain. Fayda kya?
Ek toh weights bahut kam ho jaate hain (3x3 filter = sirf 9 numbers, image chahe kitni bhi badi ho),
aur doosra, jo edge ya crack top-left mein detect hota hai wahi bottom-right mein bhi detect ho jaata
hai — isko translation equivariance bolte hain. Isiliye aerospace mein composite panel ke cracks
dhoondhne ya satellite images se runway pehchaanne ke liye CNN full-connected net se kahin better hai.
Output ka size yaad rakhne ke liye ek hi formula: Wout=⌊(Win−k+2p)/s⌋+1. Yahan
k kernel size, p padding, s stride hai. Padding image ke chaaro taraf zero laga ke size bacha
leta hai, aur stride badhao toh output chhota ho jaata hai. Ye derive karna easy hai — kernel ka left
edge jitni positions par baith sakta hai, utne hi outputs.
Pooling ka kaam hai downsampling. 2×2 window mein max lo (max-pooling) ya average lo. Isse
map chhota ho jaata hai, compute kam, aur thoda-bahut shift hone par bhi feature same rehta hai. Yaad
rakho: pooling mein koi learnable parameter nahi hota — ye fixed function hai. Aur convolution vs
cross-correlation ke chakkar mein mat pado; network toh weights khud seekh leta hai, isliye kernel
flip karne se koi farak nahi padta. Bas formula aur intuition pakad lo, exam mein aur real project
dono mein kaam aayega.