Decompose kyun karein? Kyunki hum sirf simple operations ko easily differentiate karna jaante hain. Agar hum poori computation ko simple ops ki chain ke roop mein express karein, toh chain rule local derivatives ko aapas mein jod deta hai aur poori derivative ban jaati hai.
Graph ko left-to-right evaluate karo, har intermediate value ko store karte hue. Store kyun karein? Local derivatives usually values par depend karti hain (jaise dxdsinx=cosx ko x chahiye).
Goal:∂L/∂w. Graph ke through chain karo:
∂w∂L=∂L/∂y^(y^−t)⋅∂y^/∂zσ(z)(1−σ(z))⋅∂z/∂wx
Kyun∂L/∂y^=y^−t? 21(y^−t)2 ki derivative.
Kyunσ′(z)=σ(1−σ)? Standard sigmoid identity (derive karo: σ′=(1+e−z)2e−z=σ(1−σ)).
Kyun∂z/∂w=x? z=wx+bw mein linear hai.
Autograd backward pass mein exactly yeh teen numbers compute karta hai aur unhe multiply karta hai. Tumhare taraf se koi calculus nahi.
Recall Feynman: ek 12-saal ke bachche ko samjhao
Socho ek machine chhote chhote gears se bani hai (add, multiply, sin). Tum input knob ghoomao aur answer nikalte hai. Ab tum poochho: "Agar main yeh ek gear thoda sa wiggle karoon, toh final answer kitna wiggle karega?" Autograd iska jawab output se shuru hokar gear-by-gear peeche chalta hua deta hai, har gear par yeh multiply karta hai ki woh apne neighbour ke liye kitna sensitive hai. Agar ek gear do doosron se juda hai, tum dono wiggle-effects ko add karte ho. Yeh ek baar karo aur tum seekh lo ki har knob answer ko kaise affect karta hai — toh tum jaante ho ki har knob ko kis direction mein nudge karo taaki answer better ho.
Ek directed acyclic graph jiske nodes variables hain aur edges elementary operations hain jinki known local derivatives hain; yeh ek complex function ko differentiable primitives mein decompose karta hai.
Forward pass mein intermediate values kyun store karte hain?
Local derivatives usually un values par depend karti hain (jaise d/dx sin x = cos x ko x chahiye), isliye backprop unhe reuse karta hai.
Ek node ka adjoint (bar) kya hota hai?
Sensitivity ∂(final output)/∂(woh node) — output kitna change hoga agar node wiggle kare.
Reverse-mode update rule batao.
Har edge u→v ke liye: uˉ+=vˉ⋅∂v/∂u, fˉ=1 se seed kiya hua.
Adjoints accumulate (+=) kyun karte hain?
Ek node jo multiple children ko feed karta hai woh output ko kai paths se affect karta hai; multivariable chain rule un contributions ko sum karta hai.
Cost outputs ki sankhya ke saath scale hoti hai; loss ka ek scalar output hota hai lekin millions of inputs hote hain, isliye ek backward pass sabhi gradients deta hai ≈ ek forward pass ki cost.
Kya autograd finite differences se same hai?
Nahi. Autograd exact local derivative rules apply karta hai (koi step size h nahi), isliye iska koi truncation error nahi; finite differences approximate karte hain.
Backprop aur autograd ka kya rishta hai?
Backpropagation reverse-mode automatic differentiation hai jo neural networks par apply ki gayi hai — same algorithm.
Sigmoid σ(z) ki derivative?
σ(z)(1−σ(z)).
Har training step mein gradients zero kyun karte hain?
Kyunki .grad accumulate karta hai (+=), pichle batches ke bache hue gradients warna galat tarike se add hote rahenge.