4.10.20 · Maths › Advanced Topics (Elite Level)
Socho tum ek foggy pahaadi par khade ho aur sabse neeche pahunchna chahte ho. Tum door tak nahi dekh sakte, lekin tum feel kar sakte ho ki sabse steep neeche kaun si direction hai — woh hai − ∇ f . Toh tum us direction mein ek kadam lete ho, phir se measure karte ho, aur repeat karte ho. Gradient descent (GD) bilkul yehi hai. Convergence ki saari theory ek hi sawaal ka jawab deti hai: har kadam kitna bada hona chahiye, aur hum kitni jaldi bottom tak pahunchte hain? "
Definition Gradient descent
Ek differentiable function f : R n → R ko minimize karne ke liye, iterate karo:
x k + 1 = x k − η ∇ f ( x k )
jahan η > 0 step size (learning rate) hai.
YEH direction KYU? Saare unit directions u mein se, directional derivative ∇ f ( x ) ⊤ u hai, jo Cauchy–Schwarz se minimize hoti hai jab u = − ∇ f ( x ) /∥∇ f ( x ) ∥ ho. Isliye − ∇ f steepest descent ki direction hai.
Kuch bhi prove karne ke liye, hume control karna hoga ki f kitni "wild" ho sakti hai.
L -smoothness
f L -smooth hai agar uska gradient L -Lipschitz hai:
∥∇ f ( x ) − ∇ f ( y ) ∥ ≤ L ∥ x − y ∥.
Equivalently (twice-diff f ke liye): ∇ 2 f ( x ) ⪯ L I , yani curvature upar se L se bounded hai.
μ -strong convexity
f μ -strongly convex hai agar ∇ 2 f ( x ) ⪰ μ I (μ > 0 ), yani yeh kam se kam utni tezi se upar curve karti hai jitna curvature μ wala parabola karta hai. (Plain convexity μ = 0 wala case hai.)
Ratio κ = L / μ ≥ 1 condition number hai — yahi sab kuch control karta hai.
ISKA MATLAB KYA HAI: f ek parabola se upar sandwiched hai. Hum har step mein woh parabola minimize karte hain.
Toh η = 1/ L ke saath loss hamesha decrease hota hai (kabhi diverge nahi hota) — isliye 1/ L magic step size hai.
Method
Step / idea
Rate (strongly convex)
GD
full gradient, η = 2/ ( μ + L )
( κ + 1 κ − 1 ) k
Heavy-ball / Momentum
β ( x k − x k − 1 ) add karo
( κ + 1 κ − 1 ) k
Nesterov accelerated GD
lookahead gradient
O ( ( 1 − κ 1 ) k ) ; O ( 1/ k 2 ) convex
SGD
stochastic gradient (ek sample)
O ( 1/ k ) , chahiye η k → 0
Intuition Momentum GD se behtar KYU hai
GD ek narrow valley ke across oscillate karta hai (bada κ ). Momentum back-and-forth ko average out karta hai aur valley floor ke saath accelerate karta hai — κ ko κ mein badal deta hai. Yahi sabse bada practical win hai.
Worked example 1D quadratic
f ( x ) = 2 1 a x 2
Yahan ∇ f = a x , L = μ = a , toh κ = 1 .
Update: x k + 1 = ( 1 − η a ) x k .
Yeh step KYU? η ⋆ = 2/ ( μ + L ) = 1/ a ke saath: factor = 0 ⟹ ek hi step mein converge ho jaata hai. Perfectly conditioned problems trivial hote hain.
Worked example Anisotropic
f ( x , y ) = 2 1 ( x 2 + 100 y 2 )
Eigenvalues 1 aur 100 , toh μ = 1 , L = 100 , κ = 100 .
Best rate ρ ⋆ = 101 99 ≈ 0.98 .
Yeh step KYU? Har iteration error ko sirf 2% shrink karta hai — GD crawl karta hai. Momentum deta hai 100 + 1 100 − 1 = 11 9 ≈ 0.82 : ab 18% per step. Same problem, ~9× kam iterations.
Worked example Logistic regression ke liye
η choose karna
f L -smooth hai jisme L = 4 1 λ m a x ( X ⊤ X ) . KYU? Hessian 4 1 X ⊤ D X hai jisme D ⪯ I . η = 1/ L set karo taaki line search ke bina monotone decrease guarantee ho.
Common mistake "Bada learning rate = hamesha faster."
Kyun sahi lagta hai: bade steps har iteration mein zyada ground cover karte hain.
Fix: agar η > 2/ L ho, toh factor ∣1 − η L ∣ > 1 ho jaata hai aur GD diverge karta hai (outward oscillate). Drop term η ( 1 − L η /2 ) toh η = 2/ L ke baad negative bhi ho jaati hai. Speed sirf ( 0 , 2/ L ) mein hai; sweet spot ≈ 1/ L hai.
Common mistake "Convexity akela fast (linear) convergence deta hai."
Kyun sahi lagta hai: convex problems ka unique min hota hai, easy lagta hai.
Fix: plain convexity sirf O ( 1/ k ) deti hai. Linear ρ k rates ke liye strong convexity (μ > 0 ) chahiye. Flat-bottomed convex function (jaise x 4 ) ka min par μ = 0 hota hai aur sublinearly converge hota hai.
Common mistake "SGD ke liye constant step size use karo aur woh converge ho jaayega."
Kyun sahi lagta hai: full-batch GD ke liye perfectly kaam karta hai.
Fix: gradient noise kabhi vanish nahi hoti, toh constant η ek residual error ∝ η σ 2 chhodta hai. Tumhe η k decay karna hoga.
Recall Feynman: ek 12-saal ke bachche ko samjhao
Socho tum ek moti fog mein ek pahaadi se ball roll kar rahe ho. Tum sirf apne pairo ke neeche ka slope feel kar sakte ho, toh sabse steep taraf kadam lete ho aur repeat karte ho. Agar tumhare steps bahut bade hain toh tum valley ke across fly karoge aur doosri side par bounce karoge (diverge). Agar "bilkul sahi" hain toh tum smoothly neeche slide ho jaoge. Ek lamba patla valley annoying hota hai — tum zig-zag karte ho — jab tak ki tumhare paas ek asli rolling ball jaisa thoda momentum nahi hota, jo path ko smooth karta hai. Bumpy fog (noisy slope readings = SGD) matlab hai ki tumhe neeche ke paas chhote aur chhote steps lene chahiye, warna tum uske aas-paas jittery rehte rahoge.
Mnemonic Step-size & rate
"Two-over-L se neeche raho, theek ho; One-over-L par, monotone descent."
Rate mnemonic: "GD mein κ hai, momentum mein κ " (condition number ka square root lena = momentum ka gift).
Gradient descent update rule kya hai? x k + 1 = x k − η ∇ f ( x k )
− ∇ f steepest descent direction KYU hai?Cauchy–Schwarz se, ∇ f ⊤ u unit u par minimize hoti hai jab u = − ∇ f /∥∇ f ∥ ho.
L -smoothness define karo.∥∇ f ( x ) − ∇ f ( y ) ∥ ≤ L ∥ x − y ∥ , yani ∇ 2 f ⪯ L I .
μ -strong convexity define karo.∇ 2 f ⪰ μ I jisme μ > 0 .
Descent lemma state karo. f ( y ) ≤ f ( x ) + ∇ f ( x ) ⊤ ( y − x ) + 2 L ∥ y − x ∥ 2 .
η = 1/ L ke saath kaun sa guaranteed per-step decrease hold karta hai?f ( x k + 1 ) ≤ f ( x k ) − 2 L 1 ∥∇ f ( x k ) ∥ 2 .
Smooth convex f ke liye GD convergence rate? f ( x k ) − f ⋆ ≤ 2 k L ∥ x 0 − x ⋆ ∥ 2 = O ( 1/ k ) .
Strongly convex quadratics ke liye optimal step size? η ⋆ = 2/ ( μ + L ) .
GD ka best contraction factor (strongly convex)? ρ ⋆ = κ + 1 κ − 1 = L + μ L − μ .
Quadratics par GD converge karne ke liye η ki range? 0 < η < 2/ L .
Momentum rate kaise improve karta hai? κ ko
κ se replace karta hai: factor
κ + 1 κ − 1 .
Smooth convex (non-strong) f ke liye Nesterov ki rate? O ( 1/ k 2 ) .
SGD ko decaying step size KYU use karni chahiye? Constant η residual noise ∝ η σ 2 chhodta hai; chahiye ∑ η k = ∞ , ∑ η k 2 < ∞ .
Condition number κ kya hai? κ = L / μ ≥ 1 ; bada κ ⇒ slow GD.
1/L set karne se milta hai
Condition number kappa = L/mu