Last updated 13 November 2026
What is a loss landscape?
A loss landscape is the surface formed by plotting the loss function over the parameter space. For a neural network with millions of parameters, this is a surface in million-dimensional space. We study 2D slices to build intuition about the geometry of optimization. On TensorTonic you implement gradient descent on a non-convex loss and classify critical points from the Hessian, with tests that check your output.
Training a neural network is equivalent to navigating this landscape to find a low point (minimum). The shape of the landscape determines whether gradient descent succeeds, how fast it converges, and whether the solution generalizes to new data.
Convex Landscapes
A convex loss function has a single global minimum. Any local minimum is the global minimum. This is the ideal case: gradient descent is guaranteed to find the optimal solution (given small enough learning rate).
Convex Problems ✓
- Linear/Ridge regression
- Logistic regression
- Support Vector Machines
- Lasso (L1 regularization)
Non-Convex Problems ✗
- Neural networks (all depths)
- Matrix factorization
- Most deep learning models
- Many real-world problems
The Neural Network Challenge
Even a single hidden layer with 2 neurons creates a non-convex landscape. The composition of nonlinear activation functions guarantees non-convexity. Yet, mysteriously, SGD often finds good solutions anyway!
Interactive: Loss Landscapes
Explore different loss landscape shapes and watch gradient descent navigate them. Try the different landscape types to see how topology affects optimization.
Loss Landscape Explorer
Convex Bowl
A perfect bowl. Gradient descent always finds the global minimum (0,0).
Saddle Points
In high dimensions, saddle points are far more common than local minima. A saddle point is a critical point (zero gradient) that is a minimum in some directions and a maximum in others, like the center of a horse saddle.
Why Saddles Dominate High Dimensions
At a critical point, the Hessian has n eigenvalues (one per dimension). For a local minimum, ALL must be positive. For a saddle, some are positive, some negative.
In a million-dimensional space, the probability that all million eigenvalues happen to be positive is astronomically small. Almost all critical points are saddles.
SGD Noise
Stochastic gradients provide random perturbations that help escape flat regions around saddles.
Momentum
Accumulated velocity pushes through saddle regions even when gradients are small.
Second-Order Methods
Cubic regularization and trust-region methods explicitly detect and escape saddles.
Interactive: Escaping Saddles
Watch how SGD navigates a saddle point. The algorithm starts near the saddle (gradient ≈ 0) and must escape to make progress.
Escaping Saddle Points
Random noise will eventually perturb y off zero...
Key Insight
Stochastic noise randomly perturbs the particle. Once y becomes even slightly non-zero, the negative curvature (-2) in y amplifies this, causing rapid escape.
Why flat minima generalize better
| Flat minimum | Sharp minimum | |
|---|---|---|
| Hessian eigenvalues | Small | Large |
| Small weight change | Loss barely moves | Loss jumps |
| Typical test error | Lower | Higher |
| Favored by | Small batches, larger learning rates, SAM | Large batches, very small learning rates |
The usual explanation is that the training loss is only an estimate of the true loss. The test set's loss surface is shifted slightly from the training one, so a wide valley still has low loss after that shift while a narrow ravine can climb steeply. Keskar et al. (2017) linked large-batch training to sharper minima and a measurable generalization gap.
It is a strong heuristic rather than a law. Dinh et al. (2017) showed that rescaling a ReLU network's weights can make a minimum look arbitrarily sharp without changing the function it computes, so sharpness has to be measured carefully. Methods such as SAM still improve test accuracy in practice by steering training toward flatter regions.
Interactive: Minima Comparison
Compare sharp and flat minima. Notice how parameter perturbations affect loss differently.
Sharp vs Flat Minima
Error Sensitivity
High sensitivity. Small shifts cause large errors.
Low sensitivity. Robust to distribution shifts.
Generalization Gap
The test set is never exactly the same as the training set - it's like "shifting" the parameters slightly. Flat minima ensure that this shift doesn't lead to a catastrophe (huge loss spike).
Case Study: Understanding Training Dynamics
The Observation
You're training a neural network to classify images. The loss plateaus for 50 epochs, then suddenly drops by 30%. What's happening in the loss landscape?
The Landscape Explanation
The optimizer is likely stuck near a saddle point. The gradient is small, so progress is slow. The optimizer is "wandering" in a flat region. Eventually:
- SGD noise accumulates in an unstable direction
- Momentum builds up enough velocity to escape
- The optimizer finds a descent direction and the loss drops rapidly
The Solution
Several strategies can help escape saddle regions faster:
- Cyclical learning rates: Increase LR during plateaus to add energy
- Use momentum: Accumulates velocity to push through flat regions
- Add gradient noise: Helps escape local flat spots
- Decrease batch size: More stochastic gradients = more exploration
ML Applications & Insights
Mode Connectivity
Research shows different minima found by SGD are often connected by paths of low loss. The landscape has "tunnels" connecting good solutions. It's less rugged than once thought.
Lottery Ticket Hypothesis
Sparse subnetworks at initialization can match full network performance. This suggests the loss landscape contains special "winning tickets". Initialization matters more than we thought.
Skip Connections (ResNets)
ResNets make the loss landscape dramatically smoother. Skip connections create "highways" through the landscape, making optimization easier. This is why ResNets train better than plain deep networks.
Learning Rate Schedules
Warmup, cosine annealing, and cyclical LR are all strategies informed by understanding loss landscape geometry. They help navigate complex topologies.
Batch Size Effects
Large batches converge to sharp minima (poor generalization). Small batches add noise that helps find flat minima (better generalization). This explains the "generalization gap" as batch size increases.
Neural Architecture Search
Some architectures have inherently smoother loss landscapes. NAS methods can discover architectures that are easier to optimize, not just more accurate.
Frequently asked questions about loss landscapes
Why are saddle points more common than local minima in neural networks?
At a critical point the Hessian has one eigenvalue per parameter, and a local minimum needs every one of them to be positive. In a space with millions of dimensions it is extremely unlikely that all of them are positive, so almost all critical points are saddle points.
Why do flat minima generalize better than sharp minima?
The test loss surface is shifted slightly from the training one, so a wide valley keeps a low loss after the shift while a narrow ravine can climb steeply. The link is a heuristic, and Dinh et al. (2017) showed that rescaling a ReLU network's weights can make a minimum look sharp without changing the function it computes.
Practice this
On TensorTonic you implement this from scratch and test it in the browser.
- Gradient Descent on a Non-Convex Loss: see where gradient descent ends up on a landscape with more than one basin.
- Classify a Critical Point from the Hessian: tell minima, maxima and saddle points apart.
- Classical Momentum: the update that carries training across saddles and plateaus.
The negative gradient at every point of a loss landscape forms a vector field of arrows that point downhill, which is the path gradient descent follows.