Quiz 2

⚙️ Optimization Methods

292 words
1 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# ⚙️ Optimization Methods ## 1. 🎯 Learning Objectives - Compare batch, mini-batch, and stochastic gradient descent - Trace Momentum update with velocity - Explain Adam: adaptive learning rates + momentum - Choose appropriate optimizer for a given problem ## 2.

⚙️ Optimization Methods

1. 🎯 Learning Objectives

  • Compare batch, mini-batch, and stochastic gradient descent
  • Trace Momentum update with velocity
  • Explain Adam: adaptive learning rates + momentum
  • Choose appropriate optimizer for a given problem

2. 📖 Core Content

3.1 Gradient Descent Variants

Batch GD: θ=θηθJ(θ)\theta = \theta - \eta \cdot \nabla_\theta J(\theta) — uses ALL data per step Stochastic GD: θ=θηθJ(θ(i))\theta = \theta - \eta \cdot \nabla_\theta J(\theta^{(i)}) — uses ONE example per step Mini-batch GD: θ=θηθJ(θ(i:i+n))\theta = \theta - \eta \cdot \nabla_\theta J(\theta^{(i:i+n)}) — uses BATCH of examples
VariantPer-step CostConvergenceMemory
Batch GDO(N)Stable, smoothO(1)
SGDO(1)Noisy, can escape local minimaO(1)
Mini-batchO(batch_size)Trade-offO(batch_size)

3.2 Momentum

Momentum accelerates gradient descent by accumulating velocity:
vt=γvt1+ηθJ(θ)v_t = \gamma v_{t-1} + \eta \nabla_\theta J(\theta) θ=θvt\theta = \theta - v_t
  • γ\gamma: momentum coefficient (typically 0.9)
  • Helps overcome local minima and plateaus

3.3 RMSprop

Adaptive learning rate per parameter:
st=βst1+(1β)(θJ)2s_t = \beta s_{t-1} + (1-\beta)(\nabla_\theta J)^2 θ=θηst+ϵθJ\theta = \theta - \frac{\eta}{\sqrt{s_t + \epsilon}} \nabla_\theta J

3.4 Adam (Adaptive Moment Estimation)

Combines Momentum + RMSprop:
mt=β1mt1+(1β1)gtm_t = \beta_1 m_{t-1} + (1-\beta_1)g_t vt=β2vt1+(1β2)gt2v_t = \beta_2 v_{t-1} + (1-\beta_2)g_t^2 m^t=mt/(1β1t)\hat{m}_t = m_t / (1-\beta_1^t) v^t=vt/(1β2t)\hat{v}_t = v_t / (1-\beta_2^t) θt=θt1ηm^t/(v^t+ϵ)\theta_t = \theta_{t-1} - \eta \cdot \hat{m}_t / (\sqrt{\hat{v}_t} + \epsilon)
Default: β1=0.9,β2=0.999,ϵ=108\beta_1=0.9, \beta_2=0.999, \epsilon=10^{-8} Adam is the default optimizer for most deep learning tasks.

4. 📝 Practice Questions

Q1: With momentum γ=0.9 and learning rate η=0.01, if gradient g=[1, -2], compute the update step (assuming initial velocity 0).
Answer: v₁ = 0.9×0 + 0.01×[1,-2] = [0.01, -0.02]. θ_new = θ - [0.01, -0.02]. Next step: v₂ = 0.9×[0.01,-0.02] + 0.01×g₂. Join Discord PreviousBackpropagationNextRegularization
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.