WHY it works: derivatives of a composition factor into a product of local derivatives (chain rule). If we cache each layer's output during the forward pass, each local derivative is cheap and we multiply them together going backward.
Step 1 — forward pass (cache everything). Compute z1,a1,z2,y^,L and store them.
Why this step? Backward local derivatives (like σ′(z1)) need the cached activations; recomputing them would waste work.
Step 2 — seed the output gradient.∂y^∂L=y^−t.Why this step?L=21(y^−t)2⇒dL/dy^=(y^−t). This scalar is the "error signal" we propagate.
Step 3 — push through layer 2. Define δ2≡∂L/∂z2=∂L/∂y^⋅1=(y^−t).
∂w2∂L=δ2∂w2∂z2=δ2a1,∂b2∂L=δ2.Why this step?z2=w2a1+b2, so ∂z2/∂w2=a1, ∂z2/∂b2=1. A weight's gradient = (error at its output) × (its input).
Step 4 — cross the nonlinearity. Backprop the error into a1, then into z1:
∂a1∂L=δ2w2,δ1≡∂z1∂L=∂a1∂Lσ′(z1)=δ2w2σ′(z1).Why this step? Error flows back through the weightw2 (transpose direction) and gets modulated by the local slope σ′(z1).
Step 5 — layer 1 gradients.∂w1∂L=δ1x,∂b1∂L=δ1.
Same pattern as Step 3 — that's the recursion.
Imagine a line of people passing a wrong answer back down a hallway. The last person sees how wrong the answer is (that's the error). They whisper to the person behind them how much their choice mattered — bigger doors (weights) pass more blame, and a sleepy person (a unit that's "off") passes almost none. By the time the whisper reaches the front, everyone knows exactly how much to change. Doing it backwards means we only whisper once instead of asking every person "what if you'd chosen differently?"
Backpropagation ka core idea bilkul simple hai: neural network ek badi composed function hai (function ke andar function ke andar function), aur hume har weight ke liye gradient chahiye taaki gradient descent se training ho sake. Agar hum har weight ko thoda-thoda badal ke poora network dobara chalayein, toh millions of weights ke liye ye kaam bahut slow ho jaata. Backprop chain rule ko ulta (backward) lagaakar sirf ek forward aur ek backward pass mein saare gradients nikaal deta hai — isliye deep learning practical bana.
Kaise? Forward pass mein hum har layer ke z aur activation a ko cache kar lete hain. Phir output pe error signal δ=y^−t banate hain, aur usko peeche ki taraf bhejte hain. Har layer cross karte waqt teen cheezein hoti hain: error ko W⊤ se multiply karo (transpose, kyunki forward mein W se multiply hua tha — inverse nahi, transpose!), phir activation ka slope σ′(z) se multiply karo, aur weight ka gradient nikaalne ke liye us error ko us weight ke input se multiply karo. Yaad rakho: har weight ka gradient = uska error out × uska signal in.
Common galti: log σ′(z) multiply karna bhool jaate hain, ya W−1 lene lagte hain — dono galat. Aur jahan ek node kai jagah jaata hai, wahan saare paths ke gradients add karne padte hain (multivariable chain rule).
Aerospace mein ye kyun important hai? Jab hum CFD ya flight-test ke huge data pe neural network surrogate model train karte hain (jaise drag/lift predict karna bina full simulation ke), tab backprop hi hai jo lakhon parameters ko efficiently tune karta hai. Iske bina modern ML aerospace design loops chal hi nahi sakte.