Simple Algorithm
Machine Learning · Convergence · 30 min

The Implicit Bias of Gradient Descent

Which of many zero-loss solutions the optimizer picks.

When a model can fit its training data in infinitely many ways, the optimizer decides which fit you get. Gradient descent turns out to have strong, sometimes exactly computable preferences: the closest interpolant for least squares, the maximum margin for separable classification, sparsity or low rank for factorized models. This lesson proves the clean cases and maps where the theory stops.

What you’ll learn

  • Prove that mirror descent, and gradient descent as a special case, converges on underdetermined regression to the interpolant closest to its initialization in its own geometry.
  • State the theorem of Soudry et al. on separable logistic regression, explain the maximum-margin limit through the KKT conditions, and quantify how slow the convergence is.
  • State what is known for homogeneous networks: monotone normalized margins, KKT points of a margin problem, and directional convergence.
  • Explain the implicit bias of diagonal networks and deep matrix factorization, and the evidence that it is about rank rather than any norm.

Least squares in any geometry

For underdetermined least squares, gradient descent from w0\mathbf w_0 converges to the interpolant nearest to w0\mathbf w_0 in Euclidean distance, by the row-space argument of Generalization in Modern ML. Mirror descent replaces the Euclidean geometry by a strongly convex potential ψ\psi: it takes gradient steps in the dual variable, ∇ψ(wt+1)=∇ψ(wt)−ηt∇L(wt)\nabla\psi(\mathbf w_{t+1})=\nabla\psi(\mathbf w_t)-\eta_t\nabla L(\mathbf w_t) (Mirror Descent & Natural Gradient). Its implicit bias is the matching notion of distance, the Bregman divergence Dψ(w,w′)=ψ(w)−ψ(w′)−⟨∇ψ(w′),w−w′⟩D_\psi(\mathbf w,\mathbf w')=\psi(\mathbf w)-\psi(\mathbf w')-\langle\nabla\psi(\mathbf w'),\mathbf w-\mathbf w'\rangle.

DerivationProof
  1. ∇ψ(wt)∈∇ψ(w0)+R(X⊤)  for all t⟹∇ψ(w∞)−∇ψ(w0)=X⊤ν  for some ν\nabla\psi(\mathbf w_t)\in\nabla\psi(\mathbf w_0)+\mathcal R(X^\top)\ \ \text{for all }t\quad\Longrightarrow\quad\nabla\psi(\mathbf w_\infty)-\nabla\psi(\mathbf w_0)=X^\top\boldsymbol\nu\ \text{ for some }\boldsymbol\nu

    Every gradient is a combination of the training inputs, ∇L(w)=∑iℓ′(⟨w,xi⟩,yi) xi∈R(X⊤)\nabla L(\mathbf w)=\sum_i\ell'(\langle\mathbf w,\mathbf x_i\rangle,y_i)\,\mathbf x_i\in\mathcal R(X^\top). So the dual iterates move only within an affine subspace, and by continuity of ∇ψ\nabla\psi so does the limit:

  2. Xw=y,∇ψ(w)−∇ψ(w0)=X⊤νX\mathbf w=\mathbf y,\qquad\nabla\psi(\mathbf w)-\nabla\psi(\mathbf w_0)=X^\top\boldsymbol\nu

    Now write the optimality (KKT) conditions of the Bregman projection min⁡Dψ(w,w0)\min D_\psi(\mathbf w,\mathbf w_0) subject to Xw=yX\mathbf w=\mathbf y. The gradient of the objective in w\mathbf w is ∇ψ(w)−∇ψ(w0)\nabla\psi(\mathbf w)-\nabla\psi(\mathbf w_0), so the conditions are feasibility plus stationarity:

  3. w∞\mathbf w_\infty satisfies both: it interpolates because it is a global minimizer and the loss vanishes only at the labels, and the first step gives stationarity. The problem is convex with a strictly convex objective, so the KKT conditions are sufficient and the solution is unique: w∞\mathbf w_\infty is the Bregman projection of w0\mathbf w_0. Step sizes, and even dual momentum from w0=arg min⁡ψ\mathbf w_0=\argmin\psi (their Theorem 1b), do not change it.

With the entropy potential ψ(w)=∑iwiln⁡wi−wi\psi(\mathbf w)=\sum_iw_i\ln w_i-w_i on the simplex (exponentiated gradient) from the uniform start, the limit is the maximum-entropy interpolant (Theorem 1a). The characterization is special to potentials: steepest descent with respect to a general norm, which is not mirror descent, can converge on the squared loss to a solution that depends on the step size and is not the nearest one in that norm, even as the step size goes to zero (Gunasekar et al., 2018, Example 4 with the ℓ4/3\ell_{4/3} norm).

Check your understanding

Mirror descent with ψ(w)=12w⊤Dw\psi(\mathbf w)=\frac12\mathbf w^\top D\mathbf w for a positive definite DD is run from w0\mathbf w_0 on an underdetermined least-squares problem and converges to an interpolant. Which one?

  1. The interpolant of minimum Euclidean norm
  2. The interpolant minimizing (w−w0)⊤D(w−w0)(\mathbf w-\mathbf w_0)^\top D(\mathbf w-\mathbf w_0)
  3. The interpolant minimizing w⊤D−1w\mathbf w^\top D^{-1}\mathbf w
  4. It depends on the step sizes
Show the answer

B. The interpolant minimizing (w−w0)⊤D(w−w0)(\mathbf w-\mathbf w_0)^\top D(\mathbf w-\mathbf w_0)

For a quadratic potential, Dψ(w,w0)=12(w−w0)⊤D(w−w0)D_\psi(\mathbf w,\mathbf w_0)=\frac12(\mathbf w-\mathbf w_0)^\top D(\mathbf w-\mathbf w_0), so the limit is the nearest interpolant in the DD-norm, independent of step sizes. This is preconditioned gradient descent: the preconditioner reshapes the implicit bias, which is why changing the optimizer can change which solution, and which generalization, you get.

Separable classification: the maximum-margin direction

DerivationWhy the maximum margin (the self-consistency argument, for the exponential loss)
  1. No finite minimizer. For a separator w⋆\mathbf w_\star, w⋆⊤∇L(w)=∑iℓ′(w⊤xi) w⋆⊤xi<0\mathbf w_\star^\top\nabla L(\mathbf w)=\sum_i\ell'(\mathbf w^\top\mathbf x_i)\,\mathbf w_\star^\top\mathbf x_i<0 at every finite w\mathbf w, so there is no critical point. Gradient descent drives the loss to zero, the norm to infinity and every margin w⊤xi\mathbf w^\top\mathbf x_i to +∞+\infty (their Lemma 1).

  2. −∇L(w(t))=∑ie−w(t)⊤xixi≈e−g(t)∑i: w^⊤xi=1αixi,αi>0-\nabla L(\mathbf w(t))=\sum_ie^{-\mathbf w(t)^\top\mathbf x_i}\mathbf x_i\approx e^{-g(t)}\sum_{i:\ \hat{\mathbf w}^\top\mathbf x_i=1}\alpha_i\mathbf x_i,\qquad\alpha_i>0

    Only the closest points matter. Suppose w(t)≈g(t) w^\mathbf w(t)\approx g(t)\,\hat{\mathbf w} with g→∞g\to\infty, scaled so that min⁡iw^⊤xi=1\min_i\hat{\mathbf w}^\top\mathbf x_i=1. In the negative gradient each point carries weight e−w⊤xi≈e−g w^⊤xie^{-\mathbf w^\top\mathbf x_i}\approx e^{-g\,\hat{\mathbf w}^\top\mathbf x_i}, so the points with w^⊤xi=1\hat{\mathbf w}^\top\mathbf x_i=1 dominate and all others are exponentially suppressed:

  3. w^=∑iαixi,αi≥0,αi(w^⊤xi−1)=0,w^⊤xi≥1\hat{\mathbf w}=\sum_i\alpha_i\mathbf x_i,\qquad\alpha_i\ge0,\qquad\alpha_i\big(\hat{\mathbf w}^\top\mathbf x_i-1\big)=0,\qquad\hat{\mathbf w}^\top\mathbf x_i\ge1

    Self-consistency. For gradient flow w˙=−∇L\dot{\mathbf w}=-\nabla L to keep moving along w^\hat{\mathbf w}, the direction w^\hat{\mathbf w} must be a nonnegative combination of the points on its margin, and g˙∝e−g\dot g\propto e^{-g} forces g(t)≈log⁡tg(t)\approx\log t. Those are exactly the KKT conditions of the hard-margin SVM: stationarity with nonnegative multipliers, and complementary slackness (zero multipliers off the margin):

  4. The rigorous proof controls the residual ρ(t)\boldsymbol\rho(t). The conclusion depends on the tail: Nacson et al. (2019) show that gradient descent on linear networks of any depth converges in direction to the ℓ2\ell_2 maximum margin for a large family of super-polynomially tailed losses but not for heavier tails, and that for the exponential loss aggressive step sizes improve the rate to O(log⁡t/t)\order{\log t/\sqrt t}.

Predict before you look

Suppose the direction error behaves like c/ln⁡tc/\ln t. After 10310^3 steps it is c/ln⁡103c/\ln10^3. After how many steps will it be half that? Give the exponent kk of 10k10^k.

Show the answer

6

Halving c/ln⁡tc/\ln t requires doubling ln⁡t\ln t, that is, squaring tt: 103→10610^3\to10^6. Each further halving squares the step count again (101210^{12}, then 102410^{24}). The loss, by contrast, falls like 1/t1/t: by the time it looks converged, the direction may still be far from the maximum-margin one, so predictions on new points can keep shifting long after every training point is classified correctly.

Two extensions. Without separability, the logistic-regression iterates follow a ray: its direction is the maximum-margin predictor of a maximal linearly separable subset of the data, reached at rate O(ln⁡ln⁡t/ln⁡t)\order{\ln\ln t/\ln t}, and its offset is the bounded minimizer of the risk on the remaining data (Ji & Telgarsky, 2019). And for the exponential loss, steepest descent with respect to any norm converges to the maximum margin in that norm (Gunasekar et al., 2018, Theorem 5); the ℓ1\ell_1 case is coordinate descent, the margin-maximizing behavior studied for boosting (Why Boosting Resists Overfitting).

Homogeneous networks

A KKT point is a first-order stationary point of margin maximization, not necessarily a maximizer: the constraints are nonconvex for deep networks, and Lyu & Li note that examples where gradient descent misses the globally maximal normalized margin are easy to construct. Vardi, Shamir & Srebro (2022) went further: for several architectures with linear and ReLU activations, the KKT point reached need not even be a local optimum of the margin problem. Ji & Telgarsky (2020) showed that the direction does converge (a limit exists, not just limit points) for gradient flow on networks built from ReLU, max-pooling, linear and convolutional layers, needing only perfect classification at some time, and, for networks with locally Lipschitz gradients, that the gradients asymptotically align with the parameters.

In the infinite-width limit of two-layer homogeneous networks, Chizat & Bach (2020) characterized the limit of gradient flow on exponentially tailed losses as a max-margin classifier in a non-Hilbertian space of functions, with margins independent of the ambient dimension when the data have hidden low-dimensional structure; training only the output layer instead solves a kernel SVM, which lacks that adaptivity. For the squared loss the picture is murkier: even for a single ReLU neuron, the implicit regularization cannot be written as any explicit function of the parameters (Vardi & Shamir, 2021).

Check your understanding

What does the Lyu–Li theorem not guarantee for a homogeneous ReLU network trained to separate its data?

  1. That the normalized margin (in smoothed form) never decreases after the data are separated
  2. That the parameters grow without bound while the loss tends to zero
  3. That the limit direction attains the largest normalized margin achievable by the architecture
  4. That limit directions satisfy first-order optimality conditions of a margin-maximization problem
Show the answer

C. That the limit direction attains the largest normalized margin achievable by the architecture

KKT conditions are necessary but not sufficient for global optimality of a nonconvex problem. Gradient flow ends at a stationary point of margin maximization, possibly a poor one; only for linear models, where the problem is convex, does this pin down the maximum margin.

Factorized models: sparsity and rank

The initialization scale is a regularization knob: large initializations keep the model near its linearization (a kernel method), small ones let it select features. The transition is lopsided. A polynomially large α\alpha already gives a squared ℓ2\ell_2 norm within a factor 1+ϵ1+\epsilon of the minimum, but the ℓ1\ell_1 behavior emerges only with corrections of order 1/ln⁡(1/α2)1/\ln(1/\alpha^2), and their Theorem 2 guarantees an ℓ1\ell_1 norm within 1+ϵ1+\epsilon of the minimum only for α\alpha exponentially small in the dimension. That condition is only sufficient; they prove that a polynomially small α≤d−Ω(1/ϵ)\alpha\le d^{-\Omega(1/\epsilon)} is necessary for QαQ_\alpha to approximate a multiple of the ℓ1\ell_1 norm in every direction at once.

DerivationDepth makes the rich get richer
  1. u˙j=−ℓ′(w)∏i≠jui⟹ddtuj2=−2 ℓ′(w) w  for all j\dot u_j=-\ell'(w)\prod_{i\ne j}u_i\qquad\Longrightarrow\qquad\frac{d}{dt}u_j^2=-2\,\ell'(w)\,w\ \ \text{for all }j

    Take the simplest deep model, a scalar product w=u1u2⋯uNw=u_1u_2\cdots u_N trained by gradient flow on a loss ℓ(w)\ell(w), starting balanced (u12=⋯=uN2u_1^2=\dots=u_N^2). Each factor follows u˙j=−ℓ′(w)∏i≠jui\dot u_j=-\ell'(w)\prod_{i\ne j}u_i, so ddtuj2=−2ℓ′(w) w\frac{d}{dt}u_j^2=-2\ell'(w)\,w is the same for every jj: balance is preserved, and uj2=∣w∣2/Nu_j^2=\abs w^{2/N}.

  2. w˙=−N (w2)1−1/N ℓ′(w)\dot w=-N\,(w^2)^{1-1/N}\,\ell'(w)

    By the chain rule, w˙=∑ju˙j∏i≠jui=−ℓ′(w)∑j∏i≠jui2\dot w=\sum_j\dot u_j\prod_{i\ne j}u_i=-\ell'(w)\sum_j\prod_{i\ne j}u_i^2, and balance turns each product into ∣w∣2(N−1)/N\abs w^{2(N-1)/N}:

  3. σ˙r=−N (σr2)1−1/N ⟨∇ℓ(W), urvr⊤⟩\dot\sigma_r=-N\,(\sigma_r^2)^{1-1/N}\,\big\langle\nabla\ell(W),\,\mathbf u_r\mathbf v_r^\top\big\rangle

    For N=1N=1 this is plain gradient flow. For N≥2N\ge2 the factor (w2)1−1/N(w^2)^{1-1/N} vanishes at w=0w=0: components that start small grow slowly, large ones fast, so learning proceeds roughly one component at a time and weak components stay near zero. Arora, Cohen, Hu & Luo (2019, Theorem 3) proved the matrix version for deep linear networks W=WN⋯W1W=W_N\cdots W_1 with balanced initialization: each singular value of the product obeys the same law, with ℓ′(w)\ell'(w) replaced by the projection of the gradient onto its singular vectors.

For matrix sensing with a full-dimensional factorization X=UU⊤X=UU^\top and infinitesimal initialization, Gunasekar, Woodworth, Bhojanapalli, Neyshabur & Srebro (2017) conjectured that gradient flow finds the minimum nuclear-norm solution, and proved it when the measurement matrices commute. The evidence since points to rank rather than any norm. Arora et al. (2019) found that depth strengthens the pull toward low rank and questioned norm-based descriptions; Razin & Cohen (2020) proved that on certain matrix-completion problems the implicit regularization drives every norm and quasi-norm to infinity while the rank goes down; and Li, Luo & Lyu (2021) showed that, under assumptions, depth-2 gradient flow from infinitesimal initialization is equivalent to a greedy low-rank learning algorithm, which yields counterexamples to the nuclear-norm conjecture (Matrix Completion Theory covers the explicit nuclear-norm approach).

Noise, step sizes and stopping

Algorithm and modelImplicit bias
Gradient descent, least squares, from w0\mathbf w_0nearest interpolant to w0\mathbf w_0 in Euclidean norm
Mirror descent with potential ψ\psiBregman projection: arg min⁡Dψ(w,w0)\argmin D_\psi(\mathbf w,\mathbf w_0) over interpolants
Gradient descent, exponentially tailed loss, separable dataℓ2\ell_2 maximum-margin direction, at rate about 1/log⁡t1/\log t
Steepest descent in a norm, exponential lossmaximum margin in that norm
Homogeneous networks, gradient flowKKT points of ℓ2\ell_2 margin maximization in parameter space
Diagonal networks, initialization scale α\alphaℓ2\ell_2 (large α\alpha) to ℓ1\ell_1 (small α\alpha)
Deep matrix factorization, small initializationlow rank, not captured by any norm in some problems
Gradient flow stopped at time tt, least squaresclose to ridge with λ=1/t\lambda=1/t: risk at most 1.6862 times ridge's (Ali, Kolter & Tibshirani, 2019, Theorem 1)
SGD with label noisestationary points of the loss plus a penalty on sharpness (Damian, Ma & Lee, 2021)
The implicit bias depends on the loss, the parameterization, the geometry of the update, the initialization, the step size and the noise: the algorithm is part of the model.

The last row deserves a word. Blanc, Gupta, Valiant & Valiant (2020) showed that label-noise SGD near zero training error behaves as if penalized by the sum of squared gradient norms of the model at the data points, and Damian, Ma & Lee (2021) proved that SGD with label noise converges to a stationary point of a regularized loss L(θ)+λR(θ)L(\boldsymbol\theta)+\lambda R(\boldsymbol\theta), where RR penalizes sharp minimizers and the effective λ\lambda depends on the step size, the noise level and the batch size. Large step sizes add another effect, training at the edge of stability (Training Dynamics & the Edge of Stability), and flat minima are discussed in Why Big Networks Generalize.

Key takeaways

  • Mirror descent on underdetermined regression converges, when it interpolates, to the Bregman projection of its starting point onto the interpolants, whatever the step sizes; gradient descent is the Euclidean case.
  • On separable data, gradient descent on exponentially tailed losses converges in direction to the hard-margin SVM, w(t)=w^log⁡t+ρ(t)\mathbf w(t)=\hat{\mathbf w}\log t+\boldsymbol\rho(t), but only at rate about 1/log⁡t1/\log t, while the loss falls like 1/t1/t.
  • For homogeneous networks, normalized margins (smoothed) increase after separation and limit directions are KKT points of margin maximization, not necessarily global maximizers; the direction converges.
  • Initialization scale moves diagonal networks from minimum ℓ2\ell_2 (kernel regime) to minimum ℓ1\ell_1 (rich regime); depth makes large components grow first, and in matrix factorization the bias looks like low rank, not like any norm.
  • Stopping time, step size and label noise are regularizers too: early stopping tracks ridge with λ=1/t\lambda=1/t, and label-noise SGD penalizes sharpness.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

On separable data, the logistic loss of gradient descent decays like 1/t1/t while the margin approaches its maximum like 1/log⁡t1/\log t. What follows?

  1. Stopping as soon as the training loss is tiny can leave a classifier far from the maximum-margin one; its margin keeps improving if training continues
  2. Once the training loss is tiny, the classifier has converged
  3. The weights converge to a finite vector
  4. The direction converges faster than the loss
Show the answer

A. Stopping as soon as the training loss is tiny can leave a classifier far from the maximum-margin one; its margin keeps improving if training continues

Loss and direction converge on very different time scales: the loss can be exponentially small in log⁡t\log t before the direction is close. Training past zero training error keeps enlarging the normalized margin, which can still change predictions on test points.

Question 2

Gradient descent on the logistic loss is run on linearly separable data. Which training points determine the direction it converges to?

  1. All points equally
  2. The points farthest from the decision boundary
  3. Only the support vectors of the hard-margin SVM; moving another point, while keeping it strictly outside the margin, leaves the limit unchanged
  4. The points that were misclassified at initialization
Show the answer

C. Only the support vectors of the hard-margin SVM; moving another point, while keeping it strictly outside the margin, leaves the limit unchanged

The limit direction is the hard-margin SVM solution, a nonnegative combination of the points on its margin. Points beyond the margin receive exponentially vanishing weight in the gradient, so they do not affect the limit, though they do affect the early iterates.

Question 3

Under balanced gradient flow, a depth-NN scalar factorization obeys w˙=−N(w2)1−1/Nℓ′(w)\dot w=-N(w^2)^{1-1/N}\ell'(w). What does depth N≥2N\ge2 do to a component that starts near zero?

  1. It grows at the same rate as in plain gradient descent
  2. It grows slowly at first, because (w2)1−1/N(w^2)^{1-1/N} vanishes at zero, so large components are learned first and weak ones tend to stay near zero
  3. It grows fastest, because small components have the largest gradients
  4. It is set exactly to zero, like the lasso
Show the answer

B. It grows slowly at first, because (w2)1−1/N(w^2)^{1-1/N} vanishes at zero, so large components are learned first and weak ones tend to stay near zero

The depth factor multiplies the gradient by a power of the component's own size. Components near zero barely move until the large ones have been fit: an incremental, rich-get-richer dynamic that biases toward sparse or low-rank solutions. For N=1N=1 the factor is 1 and there is no such effect.

Question 4

Razin & Cohen (2020) found matrix-completion problems on which gradient flow over a matrix factorization drives every norm and quasi-norm of the solution to infinity. What does this show?

  1. That gradient flow diverges and fails to fit the observed entries
  2. That the nuclear-norm conjecture holds for deep factorizations
  3. That explicit regularization is always needed for matrix completion
  4. That the implicit regularization in these problems cannot be described as minimizing any norm; minimizing rank is a better description
Show the answer

D. That the implicit regularization in these problems cannot be described as minimizing any norm; minimizing rank is a better description

If the solutions found have unbounded norms while fitting the data, no norm can be what is being minimized. The rank, by contrast, decreases, which supports rank-based descriptions of the implicit bias, in line with Li, Luo & Lyu's greedy low-rank characterization.

Further reading

  • D. Soudry, E. Hoffer, M. S. Nacson, S. Gunasekar & N. Srebro, "The implicit bias of gradient descent on separable data," Journal of Machine Learning Research 19, 1–57 (2018).
  • S. Gunasekar, J. Lee, D. Soudry & N. Srebro, "Characterizing implicit bias in terms of optimization geometry," Proceedings of the 35th International Conference on Machine Learning, PMLR 80, 1832–1841 (2018).
  • K. Lyu & J. Li, "Gradient descent maximizes the margin of homogeneous neural networks," International Conference on Learning Representations (2020).
  • S. Arora, N. Cohen, W. Hu & Y. Luo, "Implicit regularization in deep matrix factorization," Advances in Neural Information Processing Systems 32 (2019).
  • B. Woodworth, S. Gunasekar, J. D. Lee, E. Moroshko, P. Savarese, I. Golan, D. Soudry & N. Srebro, "Kernel and rich regimes in overparametrized models," Proceedings of the 33rd Conference on Learning Theory, PMLR 125, 3635–3673 (2020).