Skip to content

Continuous Optimization Overview

Chapters 2 through 6 built the objects: vectors, geometry, decompositions, gradients, distributions. Chapter 7 is where they get used. Machine learning algorithms run on computers, so every model in Part II reduces to the same task — find a good set of parameters — and “good” means the minimum of some objective function.

This chapter is the numerical machinery for doing that. It has two branches and one guarantee.

The book’s Figure 7.1 is a mind map, and it is worth reading before anything else because it says which ideas are load-bearing.

diagram The book's Figure 7.1, as a dependency map mermaid

Two things the book states plainly and this module measures:

  • The problems here are continuous. Data and models live in RD\mathbb{R}^D, so the variables are real-valued — as opposed to combinatorial optimization over discrete variables, which is a different subject.
  • Everything assumes differentiability. That is what gives you a gradient at every point, and §7.4 is where you go when it fails.

By convention machine learning minimises. Gradients point uphill, so you move the other way, and the whole of §7.1 is one line — Equation 7.6. Finding the best value is like finding the valleys of a landscape.

That line has exactly two failures, and the chapter is organised around them.

Failure one: it finds a valley, not the valley. The book’s opening example is (x)=x4+7x3+5x217x+3\ell(x) = x^4 + 7x^3 + 5x^2 - 17x + 3, which has two minima. Solved exactly, they sit at x=4.480268x = -4.480268 with =47.074790\ell = -47.074790 and at x=0.662381x = 0.662381 with =3.839903\ell = -3.839903 — a difference of 43.2343.23. Which one you get is decided entirely by where you start, and nothing in the gradient warns you. §7.3 is the answer: for convex functions all local minima are global, and much of machine learning is designed to be convex for exactly this reason.

Failure two: it is slow, and how slow depends on geometry you never look at. The relevant number is the condition number κ\kappa from §4.5. At κ=1000\kappa = 1000, gradient descent was still 84%84\% wrong after one hundred thousand iterations on a least-squares problem lstsq closes exactly. Momentum (§7.1.2) attacks this by changing the iteration count from O(κ)O(\kappa) to O(κ)O(\sqrt{\kappa}) — a measured 71×71\times improvement at κ=104\kappa = 10^4.

Then there is a cost problem rather than a correctness problem: one exact gradient step needs a pass over every training example. §7.1.3 replaces it with a cheap noisy estimate, and the only property that matters is unbiasedness.

pagewhat it settlesthe measurement to remember
Optimization Using Gradient DescentEq 7.6, step-size limits, conditioningiterations against step size is a U: 104104 at the optimum, 3911339113 at 0.09970.0997, divergence at 0.09980.0998
Momentum and Stochastic Gradient DescentEq 7.11–7.15momentum’s step size is 16.3%16.3\% above the ceiling where plain descent diverges
Constrained Optimization and Lagrange MultipliersEq 7.17–7.28, weak dualitya nonconvex duality gap of 1.9841231.984123, with the dual optimum at an infeasible point
Convex Sets and Convex FunctionsDef 7.2, 7.3, Eq 7.31, 7.38a non-convex function passing 99.7%99.7\% of random chord tests
Linear and Quadratic ProgrammingEq 7.39–7.52an LP answer jumps between corners: 55 switches over 360°360°
Legendre-Fenchel Transform and Convex ConjugateDef 7.4, Eq 7.53–7.68ff^{**} is the convex envelope, and that loss is the duality gap
Chapter 7 Exercises and Solutionsall eleven book exercisesExercise 7.5’s program is unbounded as printed
Chapter 7 Formula Sheetevery equation in one place

If you are here for training loops, read §7.1 and stop. Equation 7.6, the 2/L2/L ceiling, momentum, and mini-batching are the whole practical story, and the first two pages cover them.

If you are here for Chapter 12’s SVM, you need §7.2 and §7.3.2 — the Lagrangian, the dual, and the quadratic program. Exercise 7.8 is the SVM with a single data point, and it is a good place to check whether the machinery has landed.

If you are here for Chapter 11’s EM algorithm, the piece you need is Jensen’s inequality, which is Equation 7.30 read as a statement about expectations.

Read the whole thing if you want the punchline, which is not in any one section: §7.2’s duality gap and §7.3.3’s convex envelope are the same fact. The Lagrangian dual is always concave, a concave function can only represent a convex envelope, and so whatever the envelope flattens is exactly what the gap loses. Convexity closes the gap because there is nothing left to flatten. Two sections, one idea — and the module measures both sides of it.

Worth knowing the boundaries, all of which §7.4 marks:

  • Non-differentiable objectives. Gradient methods are undefined at a kink. Subgradient methods exist (Shor, 1985); §7.3.3’s smoothing is the alternative this chapter demonstrates, and Exercise 7.11 shows it costs exactly γ/2\gamma/2 in accuracy.
  • Second-order methods in earnest. Newton’s method appears on this module’s §5.7 page; quasi-Newton methods like L-BFGS get a mention and no more.
  • Global optimisation of nonconvex problems. The chapter’s honest position is that you get a local minimum, and convexity is how you make that acceptable rather than how you avoid it.
  • Discrete variables. Combinatorial optimization is explicitly out of scope.
  • Chapter 7 is where the rest of Part I gets used. Training a model means minimising an objective, and by convention machine learning always minimises — negate anything you want to maximise.
  • Two branches: unconstrained (Section 7.1) and constrained (Section 7.2), plus one special class (Section 7.3) where a local answer is provably global.
  • Everything assumes differentiability, which is what supplies a gradient everywhere. Section 7.4 is where to go when that fails.
  • Equation 7.6 has exactly two failures. It finds a valley rather than the deepest one — the opening example’s two minima differ by 43.23 — and it is slow in a way governed by the condition number from Section 4.5.
  • Convexity answers the first failure, momentum and stochastic gradients answer the second and the cost respectively.
  • The chapter’s real punchline spans two sections: the Lagrangian duality gap and the convex envelope of the conjugate are the same phenomenon, because a concave dual can only ever represent a convex envelope.
  • Out of scope, deliberately: non-differentiable objectives, serious second-order methods, global optimisation of nonconvex problems, and anything discrete.

Next: start at the update rule everything else repairs. Optimization Using Gradient Descent

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading