Hello! Let's continue our exploration of matrix decompositions. In our last lesson, we focused on the Singular Value Decomposition (SVD) and its power for low-rank approximation, culminating in its application to parameter-efficient fine-tuning with LoRA. We saw that SVD provides a general way to understand any matrix by decomposing it into rotations and a scaling operation.
Today, we shift our focus to a different, though related, decomposition: eigendecomposition. While SVD applies to any matrix, eigendecomposition is specific to square matrices and reveals a deeper geometric truth about the transformation itself—its invariant directions. This lesson will unpack the geometric meaning of eigenvalues and eigenvectors. We will then connect this concept directly to your deep learning goals by applying it to the Hessian matrix, which will allow us to mathematically describe and interpret the curvature of the loss landscapes that our models navigate during training.
1. The Geometry of Eigenvectors and Eigenvalues
At its core, eigendecomposition asks a simple question about a linear transformation: are there any vectors whose direction is unchanged by the transformation? For a transformation represented by a square matrix , an eigenvector is a non-zero vector that, when transformed by , only gets scaled. The scaling factor is its corresponding eigenvalue . This relationship is captured by the deceptively simple equation:
This means that eigenvectors represent the stable axes of a transformation—the directions that are only stretched, squished, or flipped, but not rotated.
The 3Blue1Brown video, "Eigenvectors and eigenvalues," provides an outstanding visual intuition for this concept. It masterfully builds up from the geometric idea to the computational method for finding these special vectors and scalars.
Eigenvectors and eigenvalues | Chapter 14, Essence of linear algebra
This video builds a strong geometric and conceptual understanding of eigendecomposition.
Please watch the following segments: Geometric Intuition (watch): Focus on the core idea of a vector staying on its own span. This is the geometric definition of an eigenvector. Computational Derivation (watch): This part translates the geometric idea into the equation (A - \lambda I)v = 0. Pay close attention to how this leads to the characteristic equation det(A - λI) = 0, which is the standard method for finding eigenvalues. This connects the abstract concept to a concrete computational tool. Eigenbasis and Diagonalization (watch): This is a crucial concept. If a matrix has enough linearly independent eigenvectors to span the whole space, we can form an eigenbasis. In this basis, the transformation matrix becomes a simple diagonal matrix with the eigenvalues on the diagonal. This process of diagonalization, A = PDP^{-1}, is the essence of eigendecomposition.
The key takeaway from the video is that eigendecomposition re-expresses a transformation in its most natural coordinate system: the one defined by its own invariant directions. A transformation that might seem complex (e.g., a combination of stretching and shearing) can become a simple scaling operation along each axis in the eigenbasis. This is incredibly powerful and, as we'll see, is precisely what we need to understand the complex geometry of a neural network's loss function.
2. The Hessian Matrix and Directional Curvature
Now, let's pivot from pure linear algebra to multivariable calculus, the language of optimization. The loss function of a neural network, , is a high-dimensional scalar field where represents the model's millions or billions of parameters. During training, we use the gradient, , to find the direction of steepest descent and update the parameters. The gradient is the first-order information.
To understand the local geometry or curvature of the loss surface, we need to go to the second order. This is where the Hessian matrix comes in. The Hessian, , is the matrix of all second partial derivatives of the loss function with respect to the parameters:
Just as the gradient vector allows us to compute the first derivative in any direction (the directional derivative), the Hessian matrix allows us to compute the second derivative in any direction.
The following video provides an excellent and intuitive primer on how the gradient and Hessian relate to directional derivatives.
Gradients, Hessians, and All Those Derivative Tests
This video develops the intuition for the Hessian's role in describing curvature.
First, watch the introduction and the derivation of the gradient for computing directional first derivatives (watch). This should be a quick refresh. Then, watch the derivation of the Hessian for computing the directional second derivative (watch). The crucial formula you'll see is that the second derivative of the function f at a point, in the direction of a unit vector v, is given by v^T H v. This is the central mechanism connecting the Hessian matrix to the geometric notion of curvature.
3. Eigenvalues of the Hessian: Quantifying Curvature
We now have the two pieces of our puzzle:
- Eigendecomposition tells us the natural scaling directions (eigenvectors) and scaling factors (eigenvalues) of a square matrix.
- The Hessian matrix lets us calculate the curvature (directional second derivative) of our loss function via the expression .
Let's combine them. The Hessian matrix of a loss function is a real, symmetric matrix (assuming the loss is twice-continuously differentiable, which we take for granted in most deep learning contexts). Real symmetric matrices have a wonderful property, formalized by the Spectral Theorem (which we'll cover in the next lesson): they are always diagonalizable and their eigenvectors corresponding to distinct eigenvalues are orthogonal. We can always find an orthonormal basis of eigenvectors.
Let's consider this eigenbasis for the Hessian . Let be an eigenvector of with eigenvalue . If we are at a point in the loss landscape and we move in the direction of this eigenvector , what is the curvature?
Assuming is a unit vector, the curvature is simply the eigenvalue .
This gives us a profound geometric interpretation:
- The eigenvectors of the Hessian are the principal axes of curvature of the loss landscape. They point in the directions of maximal, minimal, and stationary curvature.
- The eigenvalues of the Hessian are the values of the curvature along these principal axes.
We can classify the local geometry based on the signs of the Hessian's eigenvalues:
- All : The surface curves upwards in all directions. We are at a local minimum. If the are large, it's a "sharp" minimum. If they are small, it's a "flat" minimum.
- All : The surface curves downwards in all directions. We are at a local maximum.
- Some and some : The surface curves up in some directions and down in others. We are at a saddle point.
- Some : There is at least one direction of zero curvature. The landscape is "flat" in this direction.

4. The Loss Landscape in Deep Learning
This analysis isn't just a theoretical exercise; it provides deep insights into the optimization challenges in deep learning. Computing the full Hessian is computationally infeasible for modern networks, but we can probe its properties using matrix-free methods (like power iteration to find the top eigenvalues) which rely only on Hessian-vector products. These studies have revealed a consistent structure in the Hessian spectrum.
[PDF] EMPIRICAL ANALYSIS OF THE HESSIAN OF OVER - Leon Bottou
This paper provides a seminal empirical study of the Hessian's properties in neural networks.
Please read the following sections: Introduction (Section 1): This sets the stage, connecting the Hessian to optimization problems and posing key questions about the geometry of the loss surface. Overview of Results (Section 1.2): Pay close attention to points 1 and 2. They introduce the core finding: the Hessian spectrum is dominated by near-zero eigenvalues, which explains the "flatness" and is a consequence of over-parameterization. Generalized Gauss-Newton Decomposition (Section 2.2): This section provides a beautiful mathematical argument for why we should expect so many near-zero eigenvalues when the number of parameters M is much larger than the number of samples N. Implications of Flatness (Section 3): Skim this section. The key experiments show that data complexity (e.g., more classes) creates more large eigenvalues (outliers), while simply making the network bigger (more over-parameterization) mainly grows the bulk of zero eigenvalues. The plots in Figures 2, 3, and 4 make this point visually.
The findings discussed in the paper by Sagun et al. are central to our modern understanding of deep learning optimization:
-
The Hessian Spectrum: The spectrum is typically composed of two parts:
- A few large positive eigenvalues (the "outliers"). These directions correspond to high curvature and are learned quickly. Their number often correlates with the structure of the data (e.g., number of classes).
- A massive number of eigenvalues that are very close to zero (the "bulk"). This corresponds to the extreme over-parameterization of neural networks. These directions are flat, and moving along them barely changes the loss.
-
Sharp vs. Flat Minima and Generalization: It is widely believed that solutions found in "flat" regions of the loss landscape (where local curvature/eigenvalues are small) generalize better than solutions in "sharp" regions (large eigenvalues). The intuition is that a flat minimum is less sensitive to small shifts between the training and test data distributions.
-
The Plague of Saddle Points: In low-dimensional spaces, we picture getting stuck in poor local minima. However, in the very high-dimensional space of neural network parameters, true local minima are rare. Most critical points (where the gradient is zero) are saddle points. Optimization algorithms must be able to navigate these landscapes and escape the saddle points by finding directions of negative curvature (given by eigenvectors with negative eigenvalues).
Conclusion
In this lesson, we have connected the abstract linear algebra concept of eigendecomposition to the very practical problem of understanding and optimizing deep neural networks.
Key Takeaways:
- Eigendecomposition () breaks down a square matrix into its fundamental scaling directions (eigenvectors) and scaling factors (eigenvalues).
- The Hessian matrix contains the second-order information about a loss function. The curvature in any direction is given by .
- The eigenvectors of the Hessian are the principal axes of curvature of the loss landscape.
- The eigenvalues of the Hessian are the curvature values along these axes. Their signs tell us whether we are at a minimum, maximum, or saddle point. Their magnitudes tell us if the curvature is sharp or flat.
- The Hessian spectrum of deep networks is characterized by a "bulk" of near-zero eigenvalues (due to over-parameterization) and a few "outlier" large eigenvalues (related to data structure), creating a landscape dominated by flat regions and saddle points.
In our next lesson, we will delve into the Spectral Theorem. This is the theorem that guarantees that symmetric matrices (like the Hessian, covariance matrices, and kernel matrices) have the nice properties we relied on today, such as having real eigenvalues and an orthonormal basis of eigenvectors. This will be a key building block for understanding Principal Component Analysis (PCA).