1.2.12 · HinglishCalculus & Optimization Basics

Gradient descent intuition and update rule

2,037 words9 min readRead in English

1.2.12 · AI-ML › Calculus & Optimization Basics

Core Idea

Yeh kyun kaam karta hai: Gradient steepest increase ki direction mein point karta hai. Isliye steepest decrease ki taraf point karta hai. Gradient ke opposite direction mein baar baar move karke, hum minimum ki taraf "neeche roll" karte hain.


The Mathematics: Update Rule Derive Karna

Step 1: First-Order Taylor Approximation

Shuru karo is baat se ki hum gradients use kyun kar sakte hain. Ek point ke aas paas, loss function ko approximate kiya ja sakta hai:

Yeh step kyun? Taylor's theorem kehta hai ki koi bhi smooth function locally linear hoti hai. Gradient humein batata hai ki chote ke liye kaise change hoti hai.

Step 2: Sabse Acha Direction Chuno

Hum woh dhundhna chahte hain jo ko sabse zyada decrease kare. Loss mein change hai:

Iske liye negative hona zaroori hai (loss decrease ho), humein chahiye .

Key insight: Dot product , jahan gradient aur humare step direction ke beech ka angle hai.

Yeh sabse zyada negative tab hota hai jab , matlab — hum gradient ke bilkul opposite move karte hain!

Step 3: Step Size Control Karo

Agar hum set karein, toh hum overshoot kar sakte hain. Step ko scale karne ke liye learning rate introduce karo:

Yeh step kyun? Gradient direction deta hai, lekin optimal magnitude nahi. humein yeh tune karne deta hai ki hum kitni aggressively descend karein.

Figure — Gradient descent intuition and update rule

Worked Examples


Common Mistakes


Deep Dive: Yeh Update Rule Locally Optimal Kyun Hai

Sawaal: Kya gradient direction provably sabse best local direction hai?

Jawaab: Haan, infinitesimal steps ke liye! Yeh raha rigorous argument:

Hum solve karna chahte hain:

First-order Taylor use karke:

Yeh tab minimize hota hai jab , ke antiparallel ho:

se scale karke (jo absorb karta hai), hum recover karte hain:

Conclusion: Gradient descent local neighborhood mein steepest descent method hai.


Learning Rate: The Critical Hyperparameter

Rule of thumb: Quadratic losses ke liye, stability ke liye zaroori hai:

jahaan , ki largest eigenvalue hai.

Kyun? Update ban jaata hai . Yeh tabhi converge hoga jab ki eigenvalues mein hon.


Doosre Concepts se Connections

  • Loss Functions — Gradient descent koi bhi differentiable loss minimize karta hai
  • Backpropagation — Neural networks mein efficiently compute karta hai
  • Learning Rate Schedules ke liye adaptive strategies (decay, warm-up)
  • Stochastic Gradient Descent — Full dataset ki jagah mini-batches use karta hai
  • Momentum and Adam — Velocity/adaptive rates ke saath enhanced GD
  • Convex Optimization — Convex ke liye GD global minimum guarantee karta hai
  • Local Minima and Saddle Points — Non-convex landscapes mein challenges
  • Second-Order Methods — Newton's method sirf gradient nahi, Hessian bhi use karta hai


Recall Ek 12-Saal ke Bacche ko Samjhao

Socho tum ek video game khel rahe ho jahan tum ek pahaad par maze mein faase ho, aur tumhe neeche khazaana dhundhna hai. Lekin bahut zyaada fog hai — tum sirf apne paon dekh sakte ho!

Tumhari strategy yeh hai:

  1. Zameen feel karo. Kaun sa taraf neeche jhukta hai? Yahi tumhara hint hai.
  2. Neeche ki taraf ek chota sa step lo.
  3. Ruko aur phir feel karo. Repeat karo.

Gradient descent exactly yehi hai! Tumhara "zameen feel karna" gradient (dhaalan) calculate karna hai. "Neeche step lena" tumhari position ko is rule se update karna hai:

"Step size" ko learning rate kehte hain. Bahut bada ho toh tum trip karke khazaane se aage nikal jaoge. Bahut chota ho toh tumhe wahan pahunchne mein zamaana lag jaega.

Machine learning mein, "khazaana" woh best model parameters hain jo tumhari predictions ko super accurate banate hain!


Flashcards

What is the gradient descent update rule? :: , where is the learning rate and is the gradient at .

Why do we use the NEGATIVE gradient in gradient descent?
The gradient points in the direction of steepest INCREASE of the loss. We want to DECREASE loss, so we move in the opposite direction: .

What happens if the learning rate is too large? :: The updates overshoot the minimum, causing the loss to oscillate or diverge instead of converging. The linear approximation (Taylor expansion) breaks down.

What happens if the learning rate is too small? :: Convergence is extremely slow — the algorithm takes tiny steps and requires many iterations to reach the minimum.

In the hill analogy, what does the gradient represent?
The gradient represents the direction and stepness of the slope. It points UPHILL (stepest ascent), so we go the opposite way to descend.
Derive the gradient descent direction from first principles.
Using Taylor expansion: . To minimize the change, we need . This is most negative when is antiparallel to , giving .
What is the "stepest descent" property of gradient descent?
Among all directions with the same step magnitude, the negative gradient direction produces the largest decrease in the loss function (locally, under first-order approximation).
In Example 1 (), why does ?
Each update multiplies the current value by (since and ), forming a geometric sequence converging to 0.

Concept Map

slope measured by

points to steepest increase

justifies local linearity of

expands using

forms

most negative at 180 deg

equals

scales step size of

combined with eta gives

iterated to reach

Loss function L theta

Gradient of L

Negative gradient

Taylor approximation

Dot product with cos alpha

Steepest descent direction

Learning rate eta

Update rule

Local minimum theta*