Why optimization is easy in theory and hard in practice
Convexity determines whether gradient descent is guaranteed to find the global minimum. Linear regression and logistic regression have convex loss functions — gradient descent always finds the best solution. Neural networks do not — their loss surfaces are riddled with local minima, saddle points, and flat regions. Understanding convexity explains why training a neural net is fundamentally harder than training a linear model, and why we rely on tricks like momentum, normalization, and good initialization.
A convex function is shaped like a bowl — any two points on the curve, the line segment between them lies above (or on) the curve. There's only one valley, so wherever you start gradient descent, you'll end up at the same global minimum.
A non-convex function is like a mountain range — full of valleys, peaks, and flat plateaus. Gradient Descent can get trapped in a shallow local valley far from the deepest point. This is the landscape neural networks live in.
A function f is convex if for any two points x, y and any λ ∈ [0, 1]:
The function value at any interpolated point is at most the interpolated function value — the chord never dips below the curve.
Equivalently: f is convex if f''(x) ≥ 0 everywhere (non-negative second derivative — concave up). For multivariate functions: the Hessian matrix is positive semi-definite everywhere.
In high dimensions (millions of parameters), saddle points are overwhelmingly more common than local minima. The loss at a random saddle point in a deep network is typically close to the global minimum — which is why neural networks can be trained at all despite non-convexity.