One of the most enduring intuitions in deep learning is that the geometry of the loss landscape dictates how well a model will perform on unseen data. If you visualize the loss surface as a terrain of hills and valleys, optimization algorithms can converge to two kinds of minima: "sharp" minima, which sit at the bottom of narrow, steep ravines, and "flat" minima, which occupy wide, gentle basins.
For years, the consensus has been clear: flat minima generalize; sharp minima memorize. But while this intuition holds up remarkably well as an empirical rule of thumb, a deeper look reveals a profound theoretical puzzle. The relationship between flatness and generalization is not a simple law of cause and effect, but a complex interplay of coordinate choices, architectural symmetries, and function-space dynamics.
The Intuition: Why Flatness Should Matter
To understand why flatness correlates with generalization, we have to consider what happens when a model transitions from training data to testing data.
When we train a neural network, we calculate the loss surface based entirely on our training set. When we evaluate the model on a test set, we are effectively drawing a new loss surface from the same underlying data distribution. Because the test set is a different sample, its loss surface will be slightly shifted or perturbed compared to the training surface.
Imagine what happens to our model's performance under this shift:
- In a sharp minimum: A tiny horizontal shift in the loss landscape pushes the model's weights up a steep cliff. The training loss was near zero, but the test loss suddenly spikes catastrophically.
- In a flat minimum: Because the basin is wide and flat, a small horizontal shift leaves the model safely on the valley floor. The test loss remains nearly identical to the training loss.
This mental model explains why optimization choices matter. For instance, Jastrzebski et al. demonstrated that the ratio of learning rate to batch size ($\eta/S$) acts as a control knob for this geometry. A high learning rate or a small batch size introduces stochastic noise that physically knocks the optimization trajectory out of narrow ravines and forces it into broad, flat valleys, consistently improving validation performance. This insight forms the bedrock of modern regularizers like Sharpness-Aware Minimization (SAM), which actively steer models toward flatter regions.
The Illusion: How Symmetries Fool Our Metrics
If flatness directly causes generalization, then measuring the curvature of a minimum—typically via the maximum eigenvalue of the Hessian matrix ($\lambda_{max}$)—should give us a reliable predictor of test performance.
It doesn't. The core reason is that parameter space is an illusion.
Consider a standard neural network utilizing Rectified Linear Units (ReLU). Because of the scale-invariance of the ReLU function, you can multiply all the weights in the first layer by a factor of 10, and divide the weights of the second layer by 10. The model's mathematical output remains completely unchanged; it represents the exact same function and makes the exact same predictions on the test set.
However, this simple rescaling drastically alters the geometry of the loss landscape. By shrinking the weights of one layer, you make the loss landscape along that coordinate axis incredibly steep, artificially inflating $\lambda_{max}$. As Cao et al. proved, neural networks do not settle into isolated local minima, but rather inhabit continuous manifolds of invariant critical points.
Because we can manipulate local flatness metrics through these reparameterization tricks without changing model behavior, Yang and Hodgkinson note that standard Hessian measurements can be highly deceptive. You can take a perfectly good, flat minimum and mathematically transform it to look arbitrarily sharp, or vice versa.
This decoupling has been verified empirically. Kaur et al. systematically showed that many common training interventions reduce $\lambda_{max}$ but completely fail to improve—and sometimes even degrade—actual generalization. Furthermore, Andriushchenko and Flammarion found that standard empirical risk minimization can occasionally find models that generalize better than the flatter solutions discovered by sharpness-aware optimizers. Flatness, as traditionally measured, is neither a necessary nor a sufficient condition for generalization.
Disentangling Symmetries with Riemannian Geometry
The failure of naive flatness metrics is especially glaring in modern architectures like Transformers, where multi-head attention and layer normalization introduce intricate mathematical symmetries. Standard coordinate-based sharpness metrics get "lost" in these redundant dimensions.
To resolve this, Dangel and Oore introduced geodesic sharpness. Instead of measuring curvature in the raw coordinate space of the weights, they leverage Riemannian geometry to "divide out" the network's internal symmetries. By measuring flatness along the true underlying manifold of the model's parameter space, they showed that the classic correlation between flatness and generalization is restored. This proves that flatness does matter, but only if you measure it in a way that respects the model's intrinsic geometry.
Shifting Focus to Function Space
If parameter-space geometry is so easily distorted, how do we capture what is truly driving generalization? A powerful alternative perspective shifts the focus from parameter space (how the loss changes when we change the weights) to function space (how the model's predictions change when we change the inputs).
Instead of looking at the Hessian of the loss, MacDonald et al. argue that the input-output Jacobian is the true missing link. The Jacobian measures the smoothness of the learned function itself. A model with a low-norm Jacobian is functionally smooth: if you slightly perturb an input image or token, the model's output prediction changes very little.
This function-space smoothness provides a much more robust predictor of generalization because it is entirely invariant to how the internal weights are scaled or parameterized. Interestingly, this smoothness seems to be an inherent inductive bias of modern architectures. Vasudeva et al. discovered that Transformers are fundamentally biased toward learning "low sensitivity" functions. Because a low-sensitivity function naturally maps large volumes of the input space to stable predictions, it inherently creates a flatter loss minimum as a secondary byproduct. Parameter-space flatness may simply be a shadow cast by function-space smoothness.
Formalizing the Link via PAC-Bayes
To move beyond empirical correlations and establish a rigorous mathematical foundation, learning theorists rely on the PAC-Bayesian framework. Traditional statistical learning theory often relies on counting parameters, which yields "vacuous" bounds (e.g., predicting an error rate bound of over 100%) when applied to over-parameterized deep networks.
PAC-Bayes solves this by evaluating the performance of a distribution of models rather than a single point. Imagine placing a Gaussian cloud of noise around your final trained weights. If you can shake the weights within a large radius and the average training error remains low, the PAC-Bayesian framework can prove a mathematically guaranteed upper bound on the test error.
Dziugaite and Roy 0001 famously used this approach to compute the first nonvacuous generalization bounds for deep networks, directly optimizing the size of this noise cloud.
Recently, the theoretical gap was tightened further by Haddouche et al., who derived dimension-independent generalization bounds that explicitly incorporate gradient variance terms. By leveraging log-Sobolev inequalities, the authors provided the formal proof that had been missing for a generation: finding a region where the loss landscape exhibits low gradient variance directly guarantees superior performance on unseen data.
Ultimately, the flatness-generalization gap is being closed from both sides. While naive geometric metrics fail because they ignore the internal language of neural network weights, combining symmetry-aware Riemannian metrics, function-space smoothness, and PAC-Bayesian theory reveals why the intuition works: true flatness is a reflection of a model that has learned a stable, robust function.
Key Foundational Work
Finding Flatter Minima with SGD (2018) — contributed 1 concept elements to this direction.
On the Flatness of Loss Surface for Two-layered ReLU Networks (2017) — contributed 1 concept elements to this direction.
Computing Nonvacuous Generalization Bounds for Deep (Stochastic) Neural Networks with Many More Parameters than Training Data (2017) — contributed 1 concept elements to this direction.