Key Moments

Loss Landscapes: Basins, River Valleys & Saddle Points | Stanford CS312 Lecture 5 with Suhas Kotha

Stanford OnlineStanford Online
Education6 min read75 min video
Nov 29, 2026|8,799 views|54|6
Save to Pod
TL;DR

Averaging fine-tuned models yields better performance, but averaging models pre-trained from scratch can lead to worse results, suggesting distinct loss landscape behaviors.

Key Insights

1

Averaging weights of two models fine-tuned on the same task can result in better performance than individual models, indicating a convex region in the loss landscape.

2

In pre-training settings, averaging model weights often leads to worse performance, suggesting models converge to separate minima or basins.

3

The 'model soups' paper demonstrated that averaging weights (uniform soup) or using a greedy approach to select contributing models can outperform individual models, especially on out-of-distribution tasks.

4

Hessian eigenvalues characterize the curvature of the loss landscape: positive eigenvalues indicate upward curvature (minima), negative indicate downward curvature (maxima), and mixed signs point to saddle points.

5

River valley landscapes suggest that optimization progresses through oscillations, with progress often hidden until learning rates are reduced or weights are averaged.

6

Theoretical models suggest saddle points are far more numerous than local minima in high-dimensional loss landscapes, and gradient descent is unlikely to get stuck in them permanently.

The complexity of loss landscapes beyond simple models

The initial mental model of a one-dimensional loss landscape with a single minimum, often used to explain gradient descent, is a significant oversimplification. Real-world loss landscapes are high-dimensional, non-convex, and their geometry is not predetermined. Factors like residual connections can smooth the landscape, while the landscape itself can be optimized to display various shapes. Unlike natural phenomena, loss landscapes are not fixed but are shaped by the models and training processes. This complexity necessitates developing new intuitive models to understand how deep learning models navigate these intricate terrains.

Basin connectivity and the power of averaging

One key mental model for understanding loss landscapes is the concept of 'basins.' Traditionally, separate training runs of deep learning models were expected to converge to different local minima due to the landscape's chaotic nature, as evidenced by high variance even with small changes in seeds. However, a surprising finding is that sometimes models trained separately can converge to the same local minimum. If two models converge to the same minimum, their weights can be averaged, and the resulting 'averaged' model often performs better than either individual model. This 'model soup' phenomenon suggests the region around the shared minimum is convex. Conversely, if averaging weights leads to poor performance, it indicates the models are in separate basins, not sharing a common minimum. This insight is particularly powerful in fine-tuning scenarios, where averaging models trained with different hyperparameters or seeds has shown significant performance gains, outperforming individual models and even ensembles.

River valley landscapes: navigating oscillations and hidden progress

Another intuitive model is the 'river valley' landscape. Here, the loss is visualized as a valley, with the 'river direction' representing progress towards lower loss and the 'valley direction' representing sharp curvature. Optimization ideally follows the river, but in reality, it often oscillates significantly, even jumping between valleys. A counter-intuitive finding is that these oscillations, while seemingly erratic, can actually accelerate progress along the riverbed. This phenomenon suggests that progress is not always monotonic; a high learning rate might cause the model to 'wobble' along the valley walls, with actual improvement only becoming apparent when the learning rate is reduced and the model settles into the valley floor. This 'hidden progress' is crucial: the visible loss might not decrease linearly, but the model is still making strides.

Critical points: saddle points versus local minima

Critical points are locations in the loss landscape where the gradient is zero. While global minima are desirable critical points, local minima and saddle points also have zero gradients. Local minima present a problem if the model gets stuck there instead of reaching the global minimum. Saddle points, where the landscape curves upwards in some directions and downwards in others, are even more concerning. In high-dimensional spaces, theoretical work suggests saddle points are far more prevalent than local minima. Furthermore, empirical evidence and theoretical analyses indicate that gradient descent, especially with techniques like weight averaging or carefully chosen learning rate schedules, is more likely to escape saddle points and converge to good local minima rather than getting stuck indefinitely.

The role of the Hessian in understanding curvature

The Hessian matrix, the second derivative of the loss function, provides a local quadratic approximation of the loss landscape. Its eigenvalues reveal the curvature: positive eigenvalues indicate upward curvature (like a bowl), negative eigenvalues indicate downward curvature (like a dome), and mixed signs point to saddle points. For instance, a positive-definite Hessian (all positive eigenvalues) characterizes a local minimum. The magnitude of eigenvalues signifies sharpness (large eigenvalues) versus flatness (small eigenvalues). While computationally expensive, understanding the Hessian allows for second-order optimization methods like Newton's method, which can theoretically converge much faster than first-order methods like gradient descent by rescaling the gradient based on curvature.

Bridging theory and practice: Gaussian-Newton matrices and empirical findings

While the Hessian can have negative eigenvalues, leading to issues with local quadratic approximations, the Gaussian-Newton matrix, a related construct, guarantees all positive eigenvalues. Empirical studies measuring Hessian and Gaussian-Newton matrix eigenvalues on real transformers show that while the Hessian often has negative eigenvalues (indicating saddle points), the Gaussian-Newton matrix remains positive-definite. This aligns with the idea that despite the complex landscape, optimization converges to stable solutions. Research also indicates that second-order methods, if feasible, could significantly accelerate convergence compared to first-order optimizers like Adam, though their computational cost remains a barrier.

Fine-tuning's structured landscape versus pre-training's chaotic nature

A key distinction emerges between fine-tuning and pre-training. In fine-tuning, the loss landscape around the target task is often described as more 'linear' or 'well-behaved.' This allows for effective weight averaging, where combining weights from different fine-tuned models can yield superior performance. Even negating or adding fine-tuned weight vectors can lead to interesting transformations. However, in pre-training, models often converge to different, unconnected basins. Averaging weights in this scenario typically degrades performance. This difference is partly attributed to permutation symmetry in pre-trained models; without proper alignment, averaged weights might not correspond to a meaningful function. Techniques like weight matching or joint training phases can help align these pre-trained models, making averaging more feasible.

Practical implications: learning rate schedules, weight averaging, and model soups

The 'river valley' model suggests that reducing the learning rate (annealing) or averaging weights (Polyak averaging) can help models settle into the optimal path. Learning rate schedules, whether cosine, linear decay, or cyclical, influence how models navigate oscillations. Weight averaging, particularly in fine-tuning, can significantly improve performance by leveraging the collective knowledge of multiple models, often outperforming individual models. The 'model soup' approach formalizes this by averaging weights or using greedy selection, demonstrating that combinations of models can achieve state-of-the-art results, especially on out-of-distribution tasks. These techniques provide practical strategies for improving model robustness and performance.

Common Questions

A loss landscape visualizes the loss of a model across different parameter values. Understanding its geometry helps in designing better optimization algorithms and predicting model behavior during training.

Topics

Mentioned in this video

More from Stanford Online

View all 204 summaries

Ask anything from this episode.

Save it, chat with it, and connect it to Claude or ChatGPT. Get cited answers from the actual content — and build your own knowledge base of every podcast and video you care about.

Get Started Free