Worked examples — Feedforward network — forward pass
5.6.7 · D3· Coding › Machine Learning (Aerospace Applications) › Feedforward network — forward pass
Shuru karne se pehle, plain-word reminders (neeche koi bhi symbol undefined nahi chhoda gaya):
Hum chaar activation curves use karenge. Har ek alag sawaal ka jawaab deta hai, isliye hum batate hain kyun hum use uthate hain — aur har ek ko plot kiya gaya hai taaki tum uska shape dekh sako computation se pehle:
Neeche ki figure sab chaar ko draw karti hai taaki unka behaviour algebra se pehle visual ho — notice karo ReLU ka hard elbow par, sigmoid ki smooth climb se tak, aur tanh ki S-shape se tak:

Aage badhne se pehle plot padho: yellow ReLU flat (dead) hai ke liye phir ka ramp; blue sigmoid left mein ke paas chipka hai aur right mein ke paas; pink tanh bhi wahi karta hai lekin aur ke beech. Ye teen shapes is page ke har "kyun ye neuron mar gaya / saturate ho gaya / negative ho gaya" moment ko explain karti hain.
yahaan aata hai: woh number hai jiska exponential curve apni khud ki height ke barabar rate se badhta hai. Hum ise sigmoid/tanh/softmax mein uthate hain kyunki yeh "smooth squashing" ki natural currency hai — yeh baad mein backprop ke dauran derivatives ko clean banata hai. Haath ke kaam ke liye bas itna chahiye: , , .
The scenario matrix
Neeche har cell ek alag cheez hai jo forward pass se puchhi ja sakti hai. Jo examples follow karte hain woh inhe sab cover karte hain.
| Cell | Scenario | Covered by |
|---|---|---|
| A | Positive-only inputs, ReLU hidden, linear output (plain regression) | Ex 1 |
| B | mein sign mix — kuch neurons fire karte hain, kuch mar jaate hain (ReLU zeroing) | Ex 2 |
| C | Zero input vector (degenerate) — bias-only output | Ex 3 |
| D | Huge input → squashing curve ka saturation (limiting behaviour) | Ex 4 |
| E | Sigmoid output ko probability ke roop mein padhna + decision threshold | Ex 5 |
| F | tanh hidden layer jo signed activations produce karta hai | Ex 6 |
| G | Softmax multi-class: raw scores → probabilities jo 1 tak sum hoon | Ex 7 |
| H | Real-world word problem (stall-warning autopilot) end-to-end | Ex 8 |
| I | Exam twist: "collapse" — koi nonlinearity nahi wala network sirf ek affine map hai | Ex 9 |
Forecast: Guess karo ki kya dono hidden neurons ReLU se bachenge, phir aage padhne se pehle guess karo.
- Pre-activation, layer 1. jahan , deta hai . Yeh step kyun? Har neuron apni weight row ka incoming activation ke saath dot product hota hai, phir bias add hota hai — scores machine mein daakhil hone ka yahi ek raasta hai.
- Activate. jahan . Dono scores positive hain, isliye ReLU unhe chhod deta hai: . Yeh step kyun? ReLU sirf negatives delete karta hai; positives unchanged pass hote hain, isliye koi neuron yahaan nahi marata — intro figure mein yellow curve par waapas dekho, dono points uske rising ramp par baithe hain.
- Output layer. . Linear output ⇒ last activation hai. Yeh step kyun? Linear output prediction ko unbounded rakhta hai — ek regression number ke liye sahi.

Figure kya dikhata hai: do blue input nodes dono yellow hidden nodes ko feed karte hain (dono alive, values aur ), jo single pink output node ko feed karte hain jisme hai — "dot, add, squash" do baar hone ki picture.
Verify: Full sum se recompute karo: . ✓ Units: jo bhi target hai (jaise N of thrust) — ek single real number, jaise ek regression head dena chahiye.
Forecast: Ek neuron ReLU se pehle negative hoga. Kaun sa, aur kya output mein uska weight abhi bhi matter karta hai?
- Pre-activation. , . Toh . Yeh step kyun? Doosri row mein feature 1 par negative weight hai, isliye woh negative score produce karta hai — ReLU ke liye ise zero karne ka classic setup.
- Activate. : , , toh . Neuron 2 is input ke liye dead hai. Yeh step kyun? ReLU har negative ko exactly set karta hai — ek hard cliff, yellow curve ke flat left part ke roop mein dikhta hai.
- Output. . Dead neuron ka weight , se multiply hota hai, kuch contribute nahi karta. Yeh step kyun? Ek silent neuron aage koi information carry nahi karta chahe uska outgoing weight kitna bhi bada ho — isliye ReLU sparse activity create karta hai.

Figure kya dikhata hai: same 2-2-1 graph, lekin doosra hidden node value par greyed out hai — uska outgoing edge faint draw kiya gaya hai yeh signal karne ke liye "koi signal pass nahi hota", isliye sirf neuron 1 aur bias se banta hai.
Verify: . ✓ Sanity: agar hum neuron 2 ko poori tarah hata dein toh answer same hoga — confirm karta hai ki yeh yahaan inactive hai.
Forecast: Sab inputs zero hone par, kya bachta hai — aur output kya read karta hai?
- Pre-activation. kisi bhi weights ke liye, toh ; pehle do entries hain . Yeh step kyun? Kisi grid ko zero column se multiply karne par zero column milta hai — input kuch contribute nahi karta, machine sirf bias par depend karti hai. Yahi bias ka the matlab hai: output jab input kuch nahi kehta.
- Activate (sigmoid). : , . Numerically toh ; toh . Kyunki yeh last layer hai, ye outputs hain. Yeh step kyun? Sigmoid har bias ko mein squash karta hai; positive bias se upar land karta hai, negative bias se neeche — intro figure mein blue curve se par padho.
Verify: Note karo kyunki sigmoid symmetric hai: . ✓
Forecast: Compute karne se pehle aur do decimals tak guess karo.
- compute karo. , toh . Yeh step kyun? Bada positive , ko vanish kar deta hai, output ko top rail par pin kar deta hai.
- compute karo. , toh . Yeh step kyun? Bada negative , ko explode kar deta hai, output ko bottom rail par pin kar deta hai.

Figure kya dikhata hai: blue sigmoid jisme par do marked dots hain jo dashed rails aur ke flat against baithe hain — curve wahan itna flat hai ki move karne se barely move karta hai, jo exactly saturation ka danger hai.
Limiting behaviour: jaise , ; jaise , . Flat rails mein curve barely change karta hai, isliye ek baar inputs huge hone ke baad network insensitive ho jaata hai — isliye hum inputs normalize karte hain.
Verify: aur 6 decimals tak; aur . ✓
Forecast: compute karo; kya yeh se upar hai ya neeche (sigmoid ki line)?
- Pre-activation. . Yeh step kyun? Ek dot product plus bias single decision score deta hai.
- Sigmoid. . Yeh step kyun? Sigmoid score ko probability mein convert karta hai taaki hum use threshold kar sakein.
- Threshold. predict fault. Yeh step kyun? exactly tab hota hai jab ; yahaan , consistent hai.
Verify: Kyunki hai, sigmoid se upar hona chahiye; wakai . ✓ Output probability ki tarah mein hai.
Forecast: Ek neuron ka score hoga, doosra nonzero. Har ek ka tanh predict karo.
- Pre-activation. ; . Yeh step kyun? Neuron 1 ek cancelling pair add karta hai → exactly ; neuron 2 reinforce karta hai → .
- tanh. : ; . Yeh step kyun? tanh zero ko seedha pass karta hai aur positive score ke liye signed value near deta hai — uska output range hidden units ko negative hone deta hai, unlike ReLU.

Figure kya dikhata hai: pink tanh curve jisme par dot hai (0 par land karta hai) aur par (near par land karta hai), dashed rails ke beech — proof ki tanh negative values output kar sakta hai, woh feature jo ReLU mein nahi hai.
Verify: exactly; . ✓ Dono mein hain.
Forecast: Kaun si class jeetegi, aur kya teenon probabilities exactly tak add honge?
- Har score ko exponentiate karo. , , . Yeh step kyun? hamesha positive hota hai aur bade scores ko bahut bade numbers mein convert karta hai — softmax ka "soft argmax" banana ka tarika.
- Sum. . Yeh step kyun? Total se divide karne par outputs tak sum karte hain, toh woh probabilities ki tarah read hote hain.
- Divide karo. , , . Yeh step kyun? Har ratio us class ka total exponential mass mein share hai.

Figure kya dikhata hai: teen chalk bars, Nominal ke liye sabse bada (), jo largest raw score se match karta hai — softmax ke ranked scores ko ek probability bar chart mein convert karne ki picture jo tak sum hoti hai.
Verify: . ✓ Argmax class 1 (Nominal) hai, jo largest raw score se match karta hai. ✓
Forecast: High stall warning ki taraf push karna chahiye. Kya output se upar jayega?
- Hidden pre-activation. . . Yeh step kyun? Do dot products sensors se hidden scores banate hain.
- ReLU. : , , toh — dono hidden neurons mar jaate hain. Yeh step kyun? Dono scores negative hain; ReLU dono ko zero karta hai, ek fully degenerate hidden layer.
- Output. ; . Yeh step kyun? Hidden layer silent hone se, sirf output bias bolta hai — aur woh kehta hai "no warning".
- Decision. no stall warning.
Verify: . ✓ Sanity: kyunki hai, sigmoid se neeche girna chahiye — consistent. (Lesson: raw yahaan theek tha; yahi net bade ke liye fire karta hai, dikhata hai ki dead-neuron case "hamesha no" nahi hota.)
Forecast: Do stacked linear maps — single equivalent slope aur intercept guess karo.
- Layer 1. (identity ise linear chhod deta hai). Yeh step kyun? Koi squashing nahi hone se, activation pre-activation ke barabar hoti hai.
- Layer 2. . Yeh step kyun? Substitute karne par dikhta hai ki pura network single affine map hai — prove karta hai ki stacked linear layers kuch haasil nahi karte. Yahi wajah hai ki real networks ko nonlinear chahiye.
- Evaluate karo. par: . Yeh step kyun? Collapsed line mein plug karne par wahi answer milta hai jo dono layers chalane par milta — neeche ki check confirm karti hai.
Verify: Direct two-step: , phir . ✓ Collapsed line se par match karta hai. ✓
Recall Quick self-check
Negative pre-activation ka ReLU kya hota hai? ::: Exactly — neuron silent hai. Activation vector , ke terms mein kaise define hota hai? ::: — curve ko ki har entry par apply karo. Input hone par, pre-activation kya hota hai? ::: Bias (kyunki ). Softmax outputs hamesha kaun si ek property satisfy karte hain? ::: Woh positive hain aur exactly tak sum karte hain. Do stacked linear layers kis cheez ke equivalent hain? ::: Ek single affine map .