Convex and Non-Convex Optimization
In convex optimization any local minimum is guaranteed to be global, while non-convex optimization navigates rugged landscapes packed with saddle points and spurious valleys.
Why Does This Exist?
The great watershed in optimization is not between linearity and non-linearity but between convexity and non-convexity.
Classical models, ordinary least squares, logistic regression and SVMs, are deliberately formulated as convex problems. For a convex function any local minimum is guaranteed to be global, so solvers started anywhere converge to the same answer without babysitting.
Deep networks shatter that guarantee. Stacked nonlinearities, normalisation, attention and weight permutation symmetries turn the loss into a non-convex surface with flat plateaus, local valleys and an enormous number of saddle points. Understanding the boundary explains why classical solvers do not transfer, why initialisation matters, and how stochastic noise escapes saddles.
For the shapes and rules underneath, start with convex sets and functions. For the certificate side of the family, see convex optimization.
Think of It Like This
A smooth salad bowl versus an expansive mountain range
Drop a steel marble into a smooth salad bowl. Wherever you release it on the rim, gravity guides it to the single lowest point. No secondary traps, no false basins, no flat ledges. That is convex optimization: downhill motion is guaranteed to find the global best.
Now drop it into a rugged mountain range in fog. It can settle in an elevated lake far above the valley floor, a suboptimal local minimum. It can roll onto a vast mesa where gravity barely pulls, a plateau. Or it can pause on a mountain pass that rises left and right but drops ahead and behind, a saddle.
In the mountains, passive rolling is not enough. You need tremors to bounce out of shallow traps and momentum to ride through passes down to the deep valley. That is non-convex optimization.
Where the analogy stops: mountains have three dimensions, where traps are common. In networks with millions of dimensions, true trapped minima are rare and saddles outnumber minima exponentially, so the marble is usually on a pass rather than in a lake.
How It Actually Works
Convexity conditions
A function on a convex domain is convex when, for all and any :
The chord between any two points sits on or above the graph. For twice-differentiable , convexity holds exactly when the Hessian is positive semi-definite everywhere:
Here is the smallest Hessian eigenvalue. Strictly positive definite everywhere means strictly convex and a unique global minimiser.
Critical points in non-convex landscapes
Where the Hessian is indefinite, eigenvalues take both signs depending on position. At a critical point with , the signs classify it, and the full procedure is in critical points and saddle points:
- Local minimum: all eigenvalues strictly positive.
- Local maximum: all eigenvalues strictly negative.
- Saddle point: at least one positive and at least one negative eigenvalue.
Why saddles dominate deep learning
In dimensions, suppose Hessian eigenvalue signs at a random critical point are roughly equally likely to be positive or negative. The probability that all come out positive, a true local minimum, is:
For that is about 1 in 1,024. For it is effectively zero. Critical points at elevated loss are overwhelmingly saddles, and first-order methods with noise or momentum follow the negative-curvature directions downhill toward wide low-loss basins.
Worked example
Two functions, one of each kind, with every number computed.
Convex quadratic. Take . The gradient is:
Setting it to zero gives and , so . The Hessian is constant:
Eigenvalues and , both positive, so is strictly convex and is the unique global minimum with value .
Saddle. Take . The gradient is , zero only at the origin. The Hessian is:
Eigenvalues and have opposite signs, so the origin is a strict saddle. Along the surface curves up (); along it curves down (). A step of along the eigenvector drops the value from to , which is the escape the diagram shows.
Code
The point of this snippet is the classification check: given a Hessian, read its eigenvalues and name the point, then verify the escape direction actually descends.
import numpy as np
def analyze_critical_point(hessian: np.ndarray) -> tuple[str, np.ndarray, bool]: """Classify a critical point using Hessian eigenvalues.""" eigenvalues = np.linalg.eigvalsh(hessian)
all_positive = bool(np.all(eigenvalues > 1e-8)) all_negative = bool(np.all(eigenvalues < -1e-8)) has_mixed = bool(np.any(eigenvalues > 1e-8) and np.any(eigenvalues < -1e-8))
if all_positive: return "Local/Global Minimum", eigenvalues, True if all_negative: return "Local Maximum", eigenvalues, False if has_mixed: return "Saddle Point", eigenvalues, False return "Degenerate / Valley", eigenvalues, bool(np.all(eigenvalues >= -1e-8))
h_convex = np.array([[4.0, 0.0], [0.0, 2.0]])print(analyze_critical_point(h_convex)[0]) # -> Local/Global Minimumprint(analyze_critical_point(h_convex)[1]) # -> [2. 4.]
h_saddle = np.array([[2.0, 0.0], [0.0, -6.0]])print(analyze_critical_point(h_saddle)[0]) # -> Saddle Pointprint(analyze_critical_point(h_saddle)[1]) # -> [-6. 2.]
step = 0.1 * np.array([0.0, 1.0]) # along the lambda = -6 eigenvectorprint(float(step[0] ** 2 - 3 * step[1] ** 2)) # -> -0.03 escape descendsThe eigenvalues and match the hand computation, and the escape step reproduces the drop.
Watch Out For
Mistaking a saddle plateau for a bad local minimum
When the loss flatlines, the usual verdict is "trapped in a bad local minimum". In over-parameterised networks genuine bad minima, all eigenvalues positive at high loss, are extraordinarily rare. The stall is almost always a saddle or an ill-conditioned ravine where the gradient norm drops below along flat directions while a descent direction still exists.
Do not add capacity to bypass a minimum that is not there. Instead introduce momentum such as Polyak momentum or Adam, shrink the minibatch to raise stochastic noise so updates jitter along the negative-curvature escape directions, or use warm-up with cosine annealing to carry the run through the flat stretch.
Trusting a zero gradient as a certificate outside convex problems
On a convex problem a zero gradient certifies a global minimum. On a neural loss it certifies almost nothing: the point can be a saddle, a plateau, or a sharp valley with far better basins nearby. Teams that port the convex stopping rule verbatim stop at the first flat spot and ship an undertrained model.
Pair the gradient norm with curvature evidence or with continued progress checks. If the norm is small but the loss is far above known-good values, treat the run as stalled on a saddle, not converged, and restart with momentum or noise before accepting the point. The certificate logic that applies here is in convex optimization; everywhere else it is only a candidate filter.
The Quick Version
- Convex means chords sit above the graph, equivalently a positive semi-definite Hessian everywhere.
- Any stationary point of a convex problem is a global minimum. That certificate is what non-convex problems lose.
- Deep losses are non-convex: stacked nonlinearities and permutation symmetries alone guarantee repeated equivalent minima.
- At a zero gradient, Hessian signs classify the point: all positive is a minimum, mixed is a saddle.
- Saddles dominate in high dimensions: all eigenvalues positive happens with probability about .
- The worked pair shows both sides: minimum value 4 at with eigenvalues 4 and 2, and a saddle at the origin with eigenvalues and .
- Escape uses momentum and minibatch noise, which follow negative-curvature directions downhill.
- A flat loss with a tiny gradient is usually a saddle, not a trap, so keep patience long and the gradient norm logged.