Training a model means minimizing a loss function. Everything that follows in this module — learning rates, momentum, Adam, the pathologies of deep-net training — is determined by the geometry of that loss surface. Convexity is the cleanest geometry there is, and it is the right place to start for two reasons: it is the setting where optimization has actual guarantees, and it supplies the two constants ( and ) that will quantify the behaviour of every algorithm in this module, convex or not.
Convex sets and convex functions
A set is convex if the line segment between any two of its points stays inside it:
A function is convex if its graph never dips below any of its chords — Jensen’s inequality in its simplest form:
If the inequality is strict for , is strictly convex (at most one minimizer). Geometrically: a convex function is a bowl, possibly a degenerate one with flat directions.
Drag the two endpoints. On the convex function every chord you can draw sits on or above the curve. On the non-convex double well, place the endpoints on the two shoulders: the chord passes under the central bump — a certificate that convexity fails. The red-shaded band is exactly where the second derivative is negative; note that it coincides with where you can make the chord test fail.
The first-order condition: tangents are global underestimators
For differentiable , convexity is equivalent to
Read this carefully, because it is the engine behind every convergence proof you will meet: the tangent plane at any point lies below the entire function. The local linear model that gradient descent trusts is never optimistic. It has an immediate, famous consequence:
If at some point of a convex function, then for every . Every stationary point is a global minimum. There is nothing to get trapped in.
This single line is what non-convex optimization gives up.
The second-order condition, and the two constants that matter
For twice-differentiable , convexity is equivalent to the Hessian being positive semidefinite everywhere: , i.e. every eigenvalue of the curvature matrix is . Two refinements bound the curvature from both sides, and these bounds are the module’s recurring characters:
-strong convexity — curvature bounded below:
The function is at least as curved as a quadratic bowl of curvature ; minimizers are unique, and distance to the optimum is controlled by the gradient norm.
-smoothness — curvature bounded above (gradient is -Lipschitz):
The function is never curvier than a quadratic of curvature ; overshooting a step is bounded, which is what will make a constant learning rate legal.
Their ratio is the condition number
the single most important scalar in this module. is a perfectly round bowl; large is a long narrow ravine — steep across, flat along. In the next lesson will appear, exactly, in the convergence rate of gradient descent; in the momentum lesson its square root will appear in the convergence rate, and that square root is the whole reason momentum exists.
Where ML sits on the convexity spectrum
| Objective | Convex? | Why |
|---|---|---|
| Least squares | Yes | Hessian always; strongly convex iff has full column rank |
| Ridge regression | Strongly convex | adds to the Hessian, so |
| Lasso | Convex, non-smooth | has a kink at 0 — needs subgradients or proximal steps |
| Logistic regression | Convex | log-sum-exp composed with a linear map; strongly convex only with regularization |
| SVM (hinge loss) | Convex, non-smooth | max of linear functions |
| Any neural network with hidden layer | No | permutation symmetry alone manufactures exponentially many equivalent minima, plus genuine saddles |
| Matrix factorization, -means, deep RL objectives | No | products of parameters / discrete structure |
Two things to take from the table. First, the classical ML core is convex — which is why those methods come with guarantees and reliable solvers, and why understanding the convex case is not an academic detour. Second, everything with a hidden layer is not, yet we will train it with the same family of algorithms. The honest framing for deep learning is: we run methods with convex-case guarantees on non-convex problems, and we study (the non-convex landscapes lesson) why that works far better than it has any right to.
What convexity buys — and the price of losing it
For a convex, -smooth , plain gradient descent with satisfies — a global guarantee from purely local steps, with no initialization cleverness required. Add strong convexity and the rate becomes geometric. Lose convexity and the honest statement collapses to: gradient descent converges to a stationary point, — which could be a minimum, a plateau, or a saddle. The gap between those two statements is the intellectual territory of this module.
A caveat worth internalizing
“Convex” is a property of the function in a given parameterization. The same statistical problem can be convex in one parameterization and non-convex in another — e.g. a linear model is convex in its weights, but factorize the weight matrix as (as LoRA and every matrix-factorization method do) and the objective is non-convex in even though nothing statistical changed.
Exercises
Work these before the next lesson
- Show that is convex directly from the chord definition. (This generalizes: a max of convex functions is convex — the hinge loss and ReLU networks’ loss pieces come from here.)
Solution
Worked solutions are part of Premium — unlock all of them for £5/month →
- 3 more exercises — each with a worked solution — are part of Premium. Unlock everything for £5/month →
References
- S. Boyd & L. Vandenberghe, Convex Optimization, Cambridge UP 2004 — chapters 2–3 are the canonical treatment (free PDF from the authors).
- Y. Nesterov, Lectures on Convex Optimization, 2nd ed., Springer 2018 — the source for the rate statements used throughout this module.
- S. Bubeck, “Convex Optimization: Algorithms and Complexity”, Foundations and Trends in ML, 2015 — compact, modern, proof-first.