3.1.10 · HinglishNeural Network Fundamentals

Computational graphs and autograd

1,775 words8 min readRead in English

3.1.10 · AI-ML › Neural Network Fundamentals


Computational graph KYA hota hai?

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.

Example function:

Ise primitives mein todein:

Figure — Computational graphs and autograd

Autograd HOW kaam karta hai: forward + backward

Forward pass (WOH KYA compute karta 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 ko chahiye).

Backward pass (chain rule, systematized)

Backward rule ko first principles se derive karna

Lo , , . Humein chahiye.

Multivariable chain rule se, do paths se ko influence karta hai ( aur ):

Ab har local derivative compute karo (local kyun? har ek ek single primitive hai):

  • (kyunki )
  • (kyunki )

Toh:


Reverse mode kyun (forward mode kyun nahi)?


Worked Example 1 — poora trace

compute karo upar di gayi values ke saath par.

Forward (Kyun? values store karo):

Backward:

  1. Seed . Kyun? .
  2. . Kyun? ki local deriv ke respect mein hai.
  3. . Kyun? symmetric hai.
  4. . Kyun? .
  5. . Kyun? ; accumulate karo kyunki se bhi flow karta hai. → .
  6. .

Formula se check karo: . ✓

Worked Example 2 — ek chhota sa neuron

, , , jahaan .

Goal: . Graph ke through chain karo:

  • Kyun ? ki derivative.
  • Kyun ? Standard sigmoid identity (derive karo: ).
  • Kyun ? 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.


Active recall

Computational graph kya hota hai?
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: , 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.
Neural nets ke liye reverse mode prefer kyun kiya jaata 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.

Connections

Concept Map

needs

solved by

is a

nodes are

edges are

each has

walked by

step 1

step 2

glued by

systematized as

computes

makes

Neural network as nested function

Gradient wrt every weight

Computational graph

Directed acyclic graph

Variables

Elementary operations

Known local derivative

Autograd

Forward pass stores values

Backward pass

Chain rule

Adjoints accumulated

Deep learning trainable at scale