Lensa ML
Lensa ML

Convexity, Minima & Saddle Points

Step 1 of 6

Convex vs Non-Convex

Why shape matters for optimization

xf(x)Convex (bowl shape)
ConvexCurvature: 0.00Wavy
Local Minima
1
Is Convex?
Yes
Global Min
0.00

A convex function curves upward everywhere, forming a single bowl. Any local minimum is automatically the global minimum -- optimization is straightforward.

Step 1 of 6: Convex vs Non-Convex

Why shape matters for optimization

xf(x)Convex (bowl shape)
ConvexCurvature: 0.00Wavy
Local Minima
1
Is Convex?
Yes
Global Min
0.00

A convex function curves upward everywhere, forming a single bowl. Any local minimum is automatically the global minimum -- optimization is straightforward.

Step 2 of 6: Local vs Global Minima

Where you start determines where you end

xf(x)basin of attraction (color = which minimum you reach)globallocalstartlocal min
LeftStart x: 2.00Right
Start x
2.00
Converged x
1.57
f(x) at min
1.19

From x=2.0, gradient descent follows the slope into a local minimum at x=1.6. It can't escape — the gradient is zero here. The true global minimum is at x=-0.5. Try moving the start to a different colored basin.

Step 3 of 6: Saddle Points

Flat but not a minimum

xysaddle point
x: 0.00
y: 0.00
df/dx
0.00
df/dy
0.00
|grad|
0.00

Near the saddle point: the gradient is close to zero, but this is NOT a minimum. f(x,y) = x^2 - y^2 curves up in x and down in y. Gradient-based methods can stall here.

Step 4 of 6: The Convexity Test

Second derivatives reveal curvature

xf(x)f(x)f''(x)tangent
ConcaveShape: 0.50Convex
Probe x: 0.50
f(x)
2.05
f'(x)
0.88
f''(x)
-1.23
Convex?
No

f''(x) < 0 here (dashed pink below zero). The curve bends downward -- this region is concave. The function is NOT globally convex.

Step 5 of 6: Loss Landscapes

Neural networks in the wild

paramslossinputhidden (4)output
Narrow (1)Width: 4Wide (20)
Width
4
Local Minima
6
Global Min
-1.90

A moderate-width network. The landscape has some bumps but is becoming smoother as width increases.

Step 6 of 6: Escaping Local Minima

Momentum and learning rate to the rescue

xf(x)start
LowMomentum: 0.50High
SmallLearning Rate: 0.080Large
Momentum
0.50
LR
0.080
Loss
3.69
Step
0

Moderate momentum accumulates velocity from past gradients, helping push through shallow local minima while staying stable.