Visual walkthrough — Convolutional neural networks — convolution operation, pooling
5.6.11 · D2· Coding › Machine Learning (Aerospace Applications) › Convolutional neural networks — convolution operation, pooli
Step 1 — Ek picture bas numbers ki grid hai
KYA HAI. Kisi bhi maths se pehle, hum agree karte hain ki computer ke liye ek "image" kya hoti hai. Yeh ek grid hai. Har ek choti cell ek pixel hai, aur har pixel mein ek number hota hai — kitna bright hai. Bada number = zyada bright.
KYUN. Jo bhi aage aata hai woh sab is grid par arithmetic hai. Agar tum grid padh sakte ho, tum poori derivation padh sakte ho. Koi calculus nahi, koi probability nahi — bas boxes mein numbers.
PICTURE. Neeche, ek grid hai. Hum rows ko index se label karte hain (jo neeche jaata hai) aur columns ko index se (jo daayein jaata hai). Toh ka matlab hai "row , column mein jo number hai". Corner cell hai — hum zero se count karte hain, jaise zyaadatar code karta hai.

Step 2 — Choti si stamp (kernel)
KYA HAI. Ab ek bahut choti grid lo — maano — aur isme apne numbers bharo. Isko kaho, yeh kernel hai (isse filter bhi kehte hain, ya parent ki Feynman story wali "stamp").
KYUN. Ek fully-connected net har pixel ko uska apna private weight deta — lakho weights, har ek apne neighbours se anjaana (yeh exactly parent note mein problem 1 aur 2 hai). Iske bajaye hum chahte hain ek chota sa weight pattern jo hum har jagah reuse karenge. Woh chota pattern hai. Iske numbers kehte hain: "jab mein image ke ek patch par baith jaata hoon, toh mujhe apne neeche ki har cell ki kitni chinta hai?"
PICTURE. Kernel ke apne chote indices hain (row, neeche) aur (column, daayein), woh bhi zero se. Toh stamp ka ek weight hai. Yahan hai, toh .

Step 3 — Stamp neeche rakho aur cell-by-cell multiply karo
KYA HAI. Stamp ko is tarah place karo ki uska top-left corner image cell par baithe. Ab har kernel cell sidha image cell ke upar hoti hai. Har overlapping pair ko aapas mein multiply karo.
KYUN. Pairs ko multiply karna aise puchna hai "kya stamp ke neeche jo pattern hai woh stamp se match karta hai?" Ek bada kernel weight ek bade pixel par baitha ho toh bada product milta hai; bada weight ek dark (chote) pixel par almost kuch bhi nahi deta. Products stamp aur patch ke beech "agreement" hain, cell by cell.
PICTURE. Arrows dekho: har kernel cell (yellow) us image cell ko point karti hai jise woh multiply karti hai (blue). Offset stamp ke andar wahi rehta hai chahe stamp image par kahan bhi baithe — yahi shifting rule hai.

- kehta hai "image row par shuru karo, phir stamp mein rows neeche jao".
- kehta hai "image column par shuru karo, phir stamp mein columns daayein jao".
Step 4 — Saare products ko add karo (+ ek nudge)
KYA HAI. Un saare products ko ek single number mein sum karo, phir ek constant (bias) add karo. Woh single number output hai.
KYUN — sum. Har product ne ek cell par agreement measure kiya. Unhe add karne se bahut saare chote "kya yeh cell match karta hai?" answers ek overall "kya poora pattern yahan aaya?" score mein badal jaate hain. Har stamp position par ek number.
KYUN — bias . Sum tab hi zero ho sakta hai jab poora patch zero ho. Real detectors ko ek aisa baseline chahiye jise upar ya neeche shift kar sako — ek threshold. woh adjustable nudge hai, kernel weights ki tarah seekha jaata hai.
PICTURE. Do nested sums bas "har stamp cell par chalo" hain — baahri sum rows par, andar wala sum columns par. Figure stamp ke chaar products ko ek output cell mein collapse hote dikhata hai.

Step 5 — Stamp slide karo: ek output cell poora map ban jaata hai
KYA HAI. Stamp ko ek column daayein move karo, Step 3–4 repeat karo → woh fill ho jaata hai. Daayein slide karte raho, phir agli row mein drop karo aur phir sweep karo. Har landing spot ek output number produce karta hai, aur milke woh ek nayi grid banaate hain — feature map.
KYUN. Yahan parent ki "weight sharing" rehti hai: wahi chaar kernel numbers ne har output cell banayi. Humne har location ke liye nayi stamp nahi seekhi — humne ek hi reuse ki. Isliye wing ka edge top-left mein detect hota hai toh bottom-right mein bhi detect hota hai (Translation equivariance vs invariance), aur isliye parameter count tiny hota hai.
PICTURE. Stamp (yellow) ko blue image par sweep karte dekho, har stop par ek green number output map mein drop hota hai. Stops ke beech ka step stride hai — yahan .

Step 6 — Output chhota kyun hota hai: landing spots ginana
KYA HAI. image mein stamp ne output diya — yeh shrink hua. Chalo count karte hain exactly kyun, taaki computing se pehle size predict kar sakein.
KYUN. Stamp ka left edge sirf wahan baith sakta hai jahan right edge image ke andar fit ho sake. Un legal left-edge positions ko gino aur output cells gin loge. Knobs aur ke liye parent ka Padding and stride dekho.
PICTURE. Aakhiri legal start index hai (yahan : columns aur ). Ek row mein woh positions hain → do cells. Figure legal starts ko green mein aur forbidden overhang ko red mein mark karta hai.

Step 7 — Edge case: bahut bada stride, aur empty map
KYA HAI. Kya hoga agar stride itna bada ho ki stamp sirf ek baar land kar sake — ya kernel image se bada ho? Formula tab bhi sahi hona chahiye.
KYUN. Ek sahi derivation degenerate inputs ko cover karti hai, sirf sundar wale nahi. Do dangers hain:
PICTURE. Teen panels: (a) poori image ke barabar → exactly ek landing → output; (b) → numerator negative → floor non-positive count deta hai, matlab koi valid output nahi (tumhe zaroor pad karna hoga); (c) padding is tarah choose karo ki ("same" convolution).

- (a) : . Ek cell.
- (b) : . Empty — kernel fit nahi ho sakta; iska ek hi ilaaj hai padding.
- (c) : . Size preserved.
Step 8 — Pooling: map ko shrink karo, meaning rakho
KYA HAI. Convolution ke baad hum aksar feature map ko downsample karte hain: isko non-overlapping windows mein kaato aur har window ko ek summary number se replace karo — uska max (max-pool) ya uska average (average-pool). Yahan weights ki stamp nahi; pooling mein zero learnable parameters hain.
KYUN. (1) Agar koi feature ek pixel hilay, window ka max usually nahi badalta — yeh local translation invariance hai (Translation equivariance vs invariance). (2) stride- pool map ko quarter kar deta hai, baad ka cost cut karta hai. (3) Baad mein har neuron original image ka ek bada patch dekhta hai — ek bada receptive field.
PICTURE. map chaar coloured blocks mein split hoti hai; har block ka sabse loud cell (max) left output mein bachta hai, block ka average right mein bachta hai.

Ek-picture summary
Upar sab kuch ek single diagram mein: image → shared stamp slide karo → feature map (formula se sized) → pool → chota, wobble-proof map. Yahi poora pipeline hai jo ek CNN baar baar stack karta hai wing panel mein cracks dhundhne ya orbit se runways dekhne ke liye (Image classification for aerospace inspection).

Recall Feynman: plain words mein poora walkthrough
Humne ek photo se shuru kiya, jo aslaan brightness numbers ki grid hai. Humne apne numbers ki ek tiny stamp banayi. Humne stamp ek patch par press ki, har stamp number ko uske neeche ke photo number se multiply kiya, chaar products add kiye, aur ek chota sa nudge add kiya — us se hume ek answer number mila. Phir humne wahi stamp ek step daayein slide ki aur phir kiya, aur phir kiya, poori photo mein, answers ki ek nayi choti grid bicha di: feature map. Hum predict kar sakte the yeh kitna chota hoga yeh count karke ki stamp kahan land karne ki permission hai — woh "IN minus K, plus pad twice, over stride, plus one" rule hai, aur yeh honestly batata hai jab stamp bilkul fit hi nahi hoti. Finally humne answer grid ko chote squares mein kaata aur har mein sirf sabse loud number rakha (max-pool), toh grid choti bhi ho gayi aur usne ek pixel hilne ki chinta bhi chhod di. Yeh stamps aur shrinks kai baar stack karo aur machine wing mein crack spot karna seekh leti hai.
Connections
- Parent topic
- Fully-connected neural networks — woh unconstrained layer jise convolution specialise karta hai.
- Padding and stride — Steps 6–7 mein aur ke knobs.
- Feature maps and receptive fields — sliding stamp kya produce karta hai.
- Translation equivariance vs invariance — sharing (Step 5) aur pooling (Step 8) kyun matter karte hain.
- Backpropagation — aur kaise seekhe jaate hain.
- Image classification for aerospace inspection — asli payoff.