Gradient Flow
Volume II, Chapter 8 — Part II. The continuous-time limit of gradient descent: derivation of gradient flow ODEs, closed-form solutions for linear models, trainability analysis via eigenvalues of the Gram matrix, parameter evolution, and the connection to the Neural Tangent Kernel.
Table of Contents
- Learning Objectives
- Prerequisites
- Notation
- Core Intuition
- The Linear Regression Model
- From Gradient Descent to Gradient Flow
- Gradient Flow for Least Squares Loss
- Evolution of the Residual
- Closed-Form Solution for Function Evolution
- Trainability and Convergence Analysis
- Evolution of Parameters
- Comparison to the Closed-Form OLS Solution
- Evolution of Model Predictions
- Distribution Over Predictions
- Common Pitfalls and Misconceptions
- Research Perspective
- Summary of Takeaways
- Exercises
Learning Objectives
After completing this chapter, you should be able to:
- Derive gradient flow as the continuous-time limit () of gradient descent.
- Write the gradient flow ODE for least squares loss.
- Derive the ODE governing the evolution of the residual vector.
- Solve the residual ODE via matrix exponential and interpret the solution.
- Characterize trainability and convergence speed from the eigenvalues of .
- Derive the closed-form parameter evolution and verify agreement with the OLS solution at .
- Compute the evolution of predictions at new test points.
- Describe how a Gaussian prior over initial parameters induces a distribution over predictions.
- Explain the connection to the Neural Tangent Kernel.
Prerequisites
- Gradient Descent — discrete update rule, learning rate, convergence conditions
- Eigenvalues and Eigenvectors — spectral decomposition, matrix exponential
- Singular Value Decomposition — pseudoinverse, rank, null space
- Linear Regression — OLS solution, design matrix
Notation
- — model parameters
- — input vector (augmented with 1 for bias)
- — data matrix (columns are inputs)
- — target vector
- — linear model
- — predictions at all training points
- — loss function
- — learning rate (step size)
- — continuous time variable
- — parameters at time
- — initial parameters
- — Moore–Penrose pseudoinverse of
Core Intuition
Gradient descent updates parameters in discrete steps of size . Gradient flow is what happens when we make the step size infinitesimally small: the discrete update becomes an ordinary differential equation (ODE). For the linear model, this ODE has an exact closed-form solution.
Why is this useful? Because the closed-form solution lets us:
- Determine whether training will converge (trainability).
- Compute how fast convergence happens (convergence speed).
- Track the exact trajectory of parameters and predictions over time.
- Understand which directions in function space are learned first.
This analysis provides the conceptual foundation for the Neural Tangent Kernel (NTK), which extends these ideas to neural networks.
Series context. This is the first part of a series on gradient-based training dynamics. Part II extends to neural networks and derives the NTK. Part III considers the Bayesian counterpart (see Bayesian Linear Regression).
Gradient Flow
HealthyThe Linear Regression Model
A linear model computes a scalar output:
where is the (augmented) input and are the parameters. For an affine model, we set so the first component of acts as the bias.
Given training pairs , we minimize the least squares loss:
In matrix form, collecting all inputs as columns of and targets into :
Geometric picture. The loss landscape is a paraboloid in . Isocontours are ellipsoids whose axes align with the eigenvectors of .
From Gradient Descent to Gradient Flow
Discrete gradient descent applies the update:
Rearranging:
Taking the limit transforms the left side into a time derivative:
Definition (Gradient Flow). Equation (6) is called gradient flow. It is an autonomous ODE describing the continuous-time evolution of parameters under infinitesimal learning rate.
Key properties:
- The loss is monotonically non-increasing along the trajectory: .
- For convex , the trajectory converges to the global minimum.
- For the linear model, the ODE is linear in and thus exactly solvable.
Gradient Flow for Least Squares Loss
Expanding the right-hand side of (6) for the quadratic loss:
Applying the chain rule to the quadratic form:
For the linear model, and , so:
This is a linear ODE with constant coefficients (since does not depend on ).
Evolution of the Residual
Define the residual vector . We seek an ODE for .
Since is constant:
Substituting (7b):
Definition (Tangent Kernel). The matrix is the tangent kernel (or empirical NTK for neural networks). For the linear model:
The residual ODE is therefore:
This is a matrix exponential decay equation.
Closed-Form Solution for Function Evolution
When is constant (which holds exactly for the linear model, since is independent of ), equation (8d) has the solution:
Substituting back and :
Verification. At : . Correct.
Interpretation. The model predictions start at their initial values and exponentially decay toward the targets . The rate of decay is governed by the eigenvalues of .
Trainability and Convergence Analysis
Spectral decomposition. Let where . Then:
Theorem 1 (Trainability). The linear model can fit the training data exactly (i.e., as ) if and only if is full rank.
Proof. The residual at time is . Each component decays as . If for all , every component decays to zero. If for some , the corresponding component remains unchanged.
Corollary. The matrix has . The kernel is full rank when (more parameters than data). In the overparameterized regime, the model can interpolate training data.
Theorem 2 (Convergence Speed). The convergence rate is dominated by the smallest nonzero eigenvalue of :
The direction associated with converges fastest; the direction associated with converges slowest.
Implication. The condition number of determines how "anisotropic" convergence is. High condition number means some directions converge much faster than others — the loss drops quickly along principal axes but slowly along the minor axis. This motivates preconditioning and adaptive methods (see Gradient Descent).
Evolution of Parameters
We can also derive a closed-form for how the parameters themselves evolve. Start from the Taylor linearization (exact for linear models):
Equating with (10) and solving for :
Applying the pseudoinverse to both sides:
This gives the exact parameter trajectory from initialization as a function of continuous time .
Comparison to the Closed-Form OLS Solution
Recall from Linear Regression that the OLS solution is:
Proposition (Asymptotic Agreement). As , the gradient flow solution (15) converges to the OLS solution (16).
Proof. Rearranging (15):
The first term is . In the second term, as because any component in the null space of is annihilated by the left-multiplication by . Therefore .
Remark. In the underdetermined case (), there are infinitely many solutions with zero training loss. Gradient flow converges to the minimum-norm solution , which is the solution closest to the initialization in the Euclidean sense. This implicit regularization is a key insight for understanding neural networks.
Evolution of Model Predictions
For a new test point , the prediction at time is . Substituting (15):
As :
Observation. The final prediction (19) depends on the training data only through (a sufficient statistic for the linear model). The prediction can be written as where . This has the same form as a kernel regression prediction — foreshadowing the NTK.
Distribution Over Predictions
Setup. Define a Gaussian prior over initial parameters:
Since is an affine function of (equation 18), and affine transformations of Gaussians are Gaussian (see Multivariate Gaussian), we can compute:
where is a scalar offset (from the terms) and is a vector depending on .
Result. The prediction follows:
Interpretation:
- At : high variance (we haven't learned anything yet), mean prediction is zero.
- As increases: variance decreases as the model commits to fitting training data; mean approaches the OLS prediction.
- Adding observation noise to the predictive variance accounts for irreducible noise.
This gives a training-time-dependent uncertainty quantification — the model becomes more certain as training progresses.
Common Pitfalls and Misconceptions
Pitfall 1: Gradient flow gradient descent. Gradient flow is the limit. With finite learning rate, trajectories can diverge, oscillate, or take different paths (especially near saddle points). Results here hold approximately for small .
Pitfall 2: The kernel is constant only for linear models. For neural networks, changes as evolves. The NTK theory shows that in the infinite-width limit, this change vanishes and the kernel becomes approximately constant — but this is an asymptotic result, not exact.
Pitfall 3: Confusing with . The kernel governing function-space evolution is (Gram matrix). The matrix governing parameter-space dynamics is . Their nonzero eigenvalues are the same, but dimensions differ.
Pitfall 4: Minimum-norm is not always desirable. Gradient flow finds the minimum-norm interpolant in the underdetermined case. For neural networks, this implicit bias can help generalization (flat minima), but can also overfit depending on the parameterization.
Research Perspective
Historical context. The ODE perspective on optimization dates to Cauchy (1847). Its application to neural network training was formalized by the Neural Tangent Kernel (Jacot et al., 2018), which showed that sufficiently wide networks behave like linear models in their tangent-space linearization. The gradient flow framework provides the mathematical scaffolding for NTK theory.
Modern relevance:
- NTK theory uses exactly the framework developed here, replacing the linear model with a first-order Taylor expansion of a neural network around its initialization.
- Lazy training regime refers to networks where parameters stay close to initialization and the tangent kernel remains approximately constant — the regime where gradient flow analysis is accurate.
- Feature learning in finite-width networks departs from the NTK regime precisely because evolves during training.
- Implicit regularization of gradient descent (converging to minimum-norm solutions) is studied extensively through the gradient flow lens.
- Scaling laws can be partially understood through the spectral structure of the tangent kernel — eigenvalues determine which "features" are learned at what rate.
Connection to subsequent parts:
- Part II replaces the linear model with a neural network → NTK derivation.
- Part III: Bayesian approach → posterior over parameters → Bayesian Linear Regression.
- Part IV: Function-space view → Gaussian Processes.
Summary of Takeaways
- Gradient flow is gradient descent with infinitesimal step size: .
- Residual evolution follows where is the tangent kernel.
- Closed-form solution: .
- Trainability requires full rank (more parameters than data).
- Convergence speed is governed by .
- Parameter evolution converges to OLS as ; in the underdetermined case, to the minimum-norm solution.
- Predictions at test points can be computed in closed form and have kernel regression structure.
- Gaussian prior over initialization → Gaussian distribution over predictions at every time .
- This is the linear-model prototype of the Neural Tangent Kernel framework.
Exercises
Exercise 1. Verify directly that is monotonically decreasing under gradient flow by computing .
Exercise 2. For a matrix with eigenvalues , compute explicitly and sketch the residual components over time.
Exercise 3. Suppose data points in dimensions. What is the rank of ? Can the model fit both points exactly? How many solutions exist?
Exercise 4. Derive the gradient flow ODE for the regularized loss . What is the equilibrium ()?
Exercise 5. Show that in the underdetermined case (), gradient flow starting from converges to , which is the minimum-norm interpolant.
Exercise 6. For the kernel , express the convergence time (time to reduce residual below ) in terms of and .
Exercise 7. Starting from equation (18), compute the mean and variance of the prediction under the prior . Express your answer in terms of .
Exercise 8. Consider a neural network with one hidden layer: . Write the tangent kernel for this model and explain why it depends on the current parameters . Under what conditions does it become approximately constant?
Exercise 9. Prove that is minimized among all solutions with zero training loss when and the system is underdetermined.