Convexity, Optimization Dynamics & Duality
Taylor approximations, Hessian condition numbers, momentum acceleration, and KKT duality.
Reference notes. Condensed summaries of each topic, not step-by-step lessons. The Core Course is the one to work through.
Inspect Architecture: Support vector machine1. The idea
Optimization algorithms traverse high-dimensional loss landscapes to locate minima. Understanding the condition number of the Hessian matrix explains why standard gradient descent oscillates in narrow ravines, how momentum damps orthogonal oscillations, and how Lagrange duality transforms constrained problems into solvable duals.
2. The math
• Let the gradient update rule be w_{t+1} = w_t - alpha * ∇f(w_t) = w_t - alpha * H w_t = (I - alpha * H) w_t.
• Eigendecompose the Hessian H = Q Lambda Q^T, where eigenvalues satisfy 0 < lambda_1 <= ... <= lambda_D.
• In the rotated coordinate frame z_t = Q^T w_t, the update decouples: z_{t+1, i} = (1 - alpha * lambda_i) z_{t, i}.
• For convergence in all directions, the contraction factor must satisfy |1 - alpha * lambda_i| < 1 for all i, which requires 0 < alpha < 2 / lambda_max.
• The optimal rate minimizing the worst-case contraction max(|1 - alpha * lambda_min|, |1 - alpha * lambda_max|) occurs when 1 - alpha * lambda_min = -(1 - alpha * lambda_max), giving alpha* = 2 / (lambda_min + lambda_max). Q.E.D.
3. How it works
4. The code (python)
import numpy as np
# Simulating Gradient Descent vs Momentum on an Ill-Conditioned Ravine (Condition Number kappa = 50)
def simulate_optimization():
# Quadratic: f(x, y) = 0.5 * (50 * x^2 + y^2) -> Hessian diag(50, 1), kappa = 50
H = np.array([[50.0, 0.0], [0.0, 1.0]])
lr = 0.035 # Near optimal for fastest convergence
# 1. Plain Gradient Descent
w_gd = np.array([1.0, 10.0])
gd_path = [w_gd.copy()]
for _ in range(30):
grad = np.dot(H, w_gd)
w_gd -= lr * grad
gd_path.append(w_gd.copy())
# 2. Momentum (Polyak Heavy Ball)
w_mom = np.array([1.0, 10.0])
v = np.zeros(2)
beta = 0.85
mom_path = [w_mom.copy()]
for _ in range(30):
grad = np.dot(H, w_mom)
v = beta * v + (1 - beta) * grad
w_mom -= lr * 3.0 * v
mom_path.append(w_mom.copy())
print(f"Final GD distance to minimum: {np.linalg.norm(w_gd):.4f}")
print(f"Final Momentum distance to minimum: {np.linalg.norm(w_mom):.4f}")
if __name__ == "__main__":
simulate_optimization()5. Check yourself
In the catalog
Finished this chapter?
The Epoch Zero newsletter
What changed in ML architectures this week: new models worth knowing, benchmark moves, and one architecture explained in plain words. Free, once a week, unsubscribe anytime.