Foundations to Frontier
Tests
B. Statistical Learning Theory › B4 Theory of deep learning

Loss-Landscape Geometry and Mode Connectivity

Neural-network loss surfaces are non-convex, yet training reliably finds good minima, and those minima are not isolated. Independently trained networks can be joined by simple curves along which the loss stays low (Garipov et al., 2018; Draxler et al., 2018). Much of the barrier on the straight line between them comes from permutation symmetry of hidden units, and aligning units nearly removes it (Entezari et al., 2022; Ainsworth et al., 2023). This topic covers symmetries, sharpness and flatness, low-dimensional visualization, Bézier-curve connectivity and weight matching. In the exercises you measure the barrier, remove most of it by permutation alignment, and learn a curved low-loss path.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Valleys joined by hidden paths

Imagine a mountain range where every valley floor is a “good” set of weights for your network. Train twice from different starting points and you land in two different valleys. Walking in a straight line from one to the other means climbing over a ridge. Yet there is often a gentle curved path between them that stays low the whole way: the valleys are really parts of one long, winding canyon. This is mode connectivity.

Two minima, one valley: mode connectivity
θ_Aθ_Bt: θ_A → θ_Btraining loss along the path
barrier on the straight line 0.191 · on the learned curve 0.0032
Dark = low loss. The two networks were trained independently and both fit the data. Walking straight from one to the other (dashed) climbs a ridge, but a simple curved path (green, one learned control point) stays low the whole way: the minima are not isolated valleys but parts of one connected low-loss region. Much of the straight-line barrier is an artefact of hidden-unit symmetry: reorder B's units to match A's (align) and the line itself gets much lower.
Why engineers care

Connected minima make model averaging, ensembling and merging possible. Averaging weights along a low-loss path, as in stochastic weight averaging or model soups, often improves robustness, and aligning networks before merging lets fine-tuned models be combined, for example perception models trained on different robots’ data.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Two independently trained networks usually end in…
  2. 2. The straight line between them typically…
  3. 3. Mode connectivity means…

Level 1: Beginner

★★☆☆☆ Basic⏱ 25 minSecondary-school mathematics: arithmetic and elementary algebra.

Symmetries create many equivalent minima

Swapping two hidden units (with their incoming and outgoing weights) leaves the function unchanged. A layer of n units has n! such permutations, and a network has the product over its layers. For odd activations like tanh, flipping the signs of a unit’s incoming and outgoing weights is also a symmetry. So every minimum has a huge number of exact copies elsewhere in weight space.

Barriers

For two minima θ_A, θ_B, the linear barrier is

B=max⁡t∈[0,1]L((1−t)θA+tθB)−12(L(θA)+L(θB)).B = \max_{t\in[0, 1]}L\big((1 - t)\theta_A + t\theta_B\big) - \tfrac12\big(L(\theta_A) + L(\theta_B)\big).

Two minima are linearly mode-connected if B is about 0.

Flatness and sharpness

The sharpness of a minimum is the largest Hessian eigenvalue λmax⁡\lambda_{\max}. Flat minima (small λmax⁡\lambda_{\max}, or small trace) are associated with better generalization and robustness, though sharpness depends on parameterization, so comparisons need care (Dinh et al., 2017).

📝 Quick check (Level 1)
0/3 answered
  1. 1. Permutation symmetries of one hidden layer with 16 units:
  2. 2. Barrier for path losses (0.1, 0.5, 0.3, 0.1):
  3. 3. Sharpness is usually measured by…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Curves between minima

Garipov et al. (2018) parameterize a quadratic Bézier curve

θ(t)=(1−t)2θA+2t(1−t)ϕ+t2θB\theta(t) = (1 - t)^2\theta_A + 2t(1 - t)\phi + t^2\theta_B

and learn the control point φ by minimizing Et∼U[0,1]L(θ(t))\mathbb E_{t\sim U[0, 1]}L(\theta(t)). The gradient is 2t(1−t)∇L(θ(t))2t(1 - t)\nabla L(\theta(t)). Near-zero-barrier curves exist for modern networks, and ensembles of points along them are diverse yet accurate.

Weight matching (Git Re-Basin)

Find the permutation π of B’s hidden units that best matches A, for example by maximizing the similarity of corresponding units’ weight vectors (a linear assignment problem per layer). Then interpolate A with π(B). For wide enough networks the linear barrier almost vanishes (Entezari et al. conjecture that, modulo permutations, SGD solutions are linearly connected).

Visualizing landscapes

Loss along a line, or on a 2-D plane through three points (as in the demo), gives honest slices. Random-direction plots need filter normalization to be comparable across networks (Li et al., 2018). Any 2-D slice of a million-dimensional surface can mislead.

🐍 Exercise 1: the barrier is mostly symmetry
Train two small tanh networks from different seeds, check that permuting hidden units leaves the loss unchanged, measure the linear-path barrier, then align B's units to A's by greedy weight matching (with sign flips) and measure the barrier again.
📝 Quick check (Level 2)
0/3 answered
  1. 1. The gradient of L(θ(t)) with respect to the Bézier control point is…
  2. 2. Weight matching solves…
  3. 3. Random-direction landscape plots need…

Level 3: Advanced

★★★★☆ Advanced⏱ 35 minGraduate level, with full derivations and proofs.

Why minima connect: overparameterization

For a network with many more parameters than constraints, the set of global minima is typically a high-dimensional manifold. Each training point imposes one equation, so with P parameters and m points the zero-loss set has dimension about P − m (Cooper, 2018). Large connected manifolds of minima make low-loss paths between solutions natural. Kuditipudi et al. (2019) prove connectivity for networks that are dropout-stable or noise-stable.

Sharpness, training and generalization

  • GD at learning rate η can’t stay in regions with λmax⁡>2/η\lambda_{\max}\gt2/\eta (edge of stability, B4.3), so large learning rates select flatter minima.
  • Sharpness-aware minimization (SAM) explicitly minimizes max⁡∥ϵ∥≤ρL(θ+ϵ)\max_{\|\epsilon\|\le\rho}L(\theta + \epsilon).
  • Reparameterization (scaling layer weights by c and 1/c in ReLU nets) can change sharpness arbitrarily without changing the function, so sharpness is not intrinsic.

Averaging and merging

If two solutions are linearly connected, their average is also a solution. Stochastic weight averaging (Izmailov et al., 2018) and model soups (Wortsman et al., 2022) average fine-tuned models from a shared pre-trained start, which are linearly connected, improving accuracy and robustness.

📝 Quick check (Level 3)
0/3 answered
  1. 1. With P parameters and m constraints, the zero-loss set has dimension about…
  2. 2. Why is sharpness not intrinsic for ReLU nets?
  3. 3. Model soups average models that…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Landscapes, measured

Exercise 1 (2→16→1 tanh, regression, two seeds). Both networks fit to training loss of order 10⁻⁴, and a random permutation of hidden units changes the loss by less than 10⁻¹⁸. The linear barrier is 0.493, about the variance of the target. After greedy weight matching it drops to 0.0113, a 40× reduction, without changing either function. (Browser numbers; results differ slightly by platform, e.g. 0.0117 on desktop CPython.)

Exercise 2. A learned Bézier curve cuts the barrier from 0.493 to 0.0033 (seed 0) and from 0.481 to 0.0061 (seed 1). The network at the curve’s midpoint, a genuinely new model, has test loss 0.0027 and 0.0037: not quite as good as the endpoints (about 10⁻⁴), but a working network. The two “isolated” solutions sit in one connected valley.

🐍 Exercise 2 (research): learning a low-loss curve
Connect two independently trained networks with a quadratic Bézier curve whose control point is learned by SGD over random t. Compare the barrier on the curve with the straight line, and check how well the midpoint network generalizes.

Landscapes in AI, robotics and aerospace

  • Model merging: combine perception models fine-tuned on different vehicles or sensors (align, then average).
  • SWA and SAM improve robustness to distribution shift, which matters for flight hardware facing new conditions.
  • Cheap ensembles from points along a connecting curve give uncertainty estimates at the cost of one training run.
  • Federated learning across robots relies on averaging compatible (aligned) models.

References

  1. T. Garipov, P. Izmailov, D. Podoprikhin, D. Vetrov, A. G. Wilson (2018). “Loss surfaces, mode connectivity, and fast ensembling of DNNs.” NeurIPS.
  2. F. Draxler, K. Veschgini, M. Salmhofer, F. Hamprecht (2018). “Essentially no barriers in neural network energy landscape.” ICML.
  3. R. Entezari, H. Sedghi, O. Saukh, B. Neyshabur (2022). “The role of permutation invariance in linear mode connectivity of neural networks.” ICLR.
  4. S. K. Ainsworth, J. Hayase, S. Srinivasa (2023). “Git Re-Basin: merging models modulo permutation symmetries.” ICLR.
  5. H. Li, Z. Xu, G. Taylor, C. Studer, T. Goldstein (2018). “Visualizing the loss landscape of neural nets.” NeurIPS.
  6. L. Dinh, R. Pascanu, S. Bengio, Y. Bengio (2017). “Sharp minima can generalize for deep nets.” ICML.
  7. P. Foret, A. Kleiner, H. Mobahi, B. Neyshabur (2021). “Sharpness-aware minimization for efficiently improving generalization.” ICLR.