2.1 Introduction to Optimization

DATA 442/642 · Week 2 · PDF · Slides

Cost functions, local versus global minima, convexity, and first- and second-order tests.

These notes walk through the lecture slides. The original deck is unchanged; use (slides) on the course hub if you want that PDF.

The figures follow Deisenroth, Faisal, and Ong, Mathematics for Machine Learning.

1. Training is optimization

Training a model is finding a good θ. Good is whatever the cost (objective) J says it is.

Training as optimization

Write J(θ):S→ℝ and solve

J(θ^)=minθ∈SJ(θ).

Usually S=ℝl. This course always minimizes. Maximizing profit P is minimizing −P.


2. Linear regression

Model y=θ⊤𝐱+ε. Fit by minimizing mean squared error on m training rows:

J(θ)=12m∑i=1m(θ⊤x(i)−y(i))2.

Each step that lowers J shrinks residuals. Better θ on the training set is the hope that predictions on new 𝐱 improve too. That hope is generalization; the math this week is the min.


3. Local versus global

A local minimum is lowest in a neighborhood: some ε>0 such that ‖θ−θ^‖<ε implies J(θ^)≤J(θ). A global minimum is lowest on all of S.

A valley on a hike is local. The lowest point in the whole range is global. Neural-net costs look like the landscape below. Many valleys. The one you land in need not be the lowest.

A nonconvex cost landscape

If J is convex,

J(tθ+(1−t)β)≤tJ(θ)+(1−t)J(β)

for all θ,β∈S and all t∈(0,1), then every local min is global.

Convex versus nonconvex

Convex J (this course) Not convex
Linear regression (MSE) Deep nets
Logistic regression (log loss) k-means
Soft-margin SVM GMM likelihood

Convex: gradient descent that reaches a local min has the global min. Nonconvex: you can stop in a valley that is not the bottom.


4. First- and second-order tests

First-order (necessary). At a local min of a smooth unconstrained J, ∇J(θ^)=0. The slope is flat.

Second-order (sufficient). If that point also has Hessian ∇2J(θ^) positive definite, it is a local min.

A zero gradient is not enough: a saddle is flat and is not a min. Week 2’s algorithms either follow −∇J or invert ∇2J.


5. Practice

  1. When does a local minimum fail to be global?

  2. Why does this course write every learning problem as a min, even when the story is “maximize likelihood”?

  3. At a point with ∇J=0, what extra fact about ∇2J lets you call it a local min rather than a saddle?