Why does early-stopped gradient descent shrink coefficients much like a ridge penalty?
answer
- think in eigen-directions of the inputs
- easy directions are learned first
- weakly determined ones stay near zero
- more steps behaves like smaller lambda
- exact only for squared loss from zero
basics
~20 sGradient descent started at zero moves fastest along directions the data determines well and slowest along weak ones, leaving the weak ones near zero. A ridge penalty shrinks exactly those most, and more iterations act like a smaller penalty.
solid answer
~40 sFor least squares fitted by full-batch gradient descent from a zero start, rotate into the eigen-directions of the input covariance and let `d_j` be direction `j`'s eigenvalue. After `t` steps the coefficient there is `1 - (1 - lr*d_j)^t` of its least-squares value; ridge multiplies the same coefficient by `d_j / (d_j + lambda)`. Both factors sit near 1 for large `d_j` — directions the data pins down — and near 0 for small `d_j`, so the two shrinkage profiles have the same shape, with `lambda` roughly `1 / (lr*t)`. The direction matters: more iterations means weaker regularization, not stronger. The equivalence is exact only for squared loss, a linear model and a zero start; elsewhere it is qualitative, and unlike ridge you have no lambda you can log and hold fixed.
go deeper
It is enough to hold the headline: stopping an iterative fit early leaves coefficients smaller than the fully converged solution, which is the same kind of effect a squared penalty produces.
Be able to state the direction and the reason — more steps means weaker shrinkage, because gradient descent from zero reaches well-determined directions quickly and weakly determined ones slowly.
Name the conditions under which the equivalence is exact and where it degrades: non-zero starts shrink toward the start, non-quadratic losses only match qualitatively, stochastic updates blur the path.
Argue the operational consequence. Early stopping regularizes for free but couples regularization to optimizer settings, so a change in learning rate silently changes model capacity across retrains unless something pins it.
### Two ways to shrink the same coefficients A ridge penalty adds `lambda * sum(w_j^2)` to a squared-error loss and pulls every coefficient toward zero, hardest where the data has least to say. Early stopping adds nothing to the loss; it just refuses to run the optimizer to convergence. The striking fact is that, in the cleanest case, these two produce nearly the same estimator — early stopping is a penalty you never wrote down. ### The clean case, stated exactly Take least squares fitted by full-batch gradient descent, started at `w = 0`, with a fixed learning rate `lr` small enough to converge. Rotate the problem into the eigen-directions of the input covariance matrix — the uncorrelated directions along which the predictors vary — and let `d_j` be the eigenvalue of direction `j`. Large `d_j` means the data varies a lot along that direction, so the least-squares coefficient there is well determined; small `d_j` means the data barely moves along it and the coefficient is mostly noise. In those coordinates the two estimators are simple multiples of the ordinary least-squares solution: ``` gradient descent, t steps: factor_j = 1 - (1 - lr * d_j)^t ridge, penalty lambda: factor_j = d_j / (d_j + lambda) ``` Read both factors at the extremes: - **Large `d_j`.** `(1 - lr*d_j)^t` decays fast, so the gradient-descent factor is close to 1 after a handful of steps. Ridge's `d_j / (d_j + lambda)` is also close to 1. Neither method shrinks the well-determined directions much. - **Small `d_j`.** `(1 - lr*d_j)^t` is approximately `1 - lr*d_j*t`, so the gradient-descent factor is approximately `lr * d_j * t` — near zero. Ridge's factor is approximately `d_j / lambda` — also near zero. Both crush the weakly-determined directions. The two shrinkage profiles have the same shape, and matching them gives the rule of thumb `lambda ≈ 1 / (lr * t)`. ### The direction that candidates get backwards More iterations means **less** regularization. Each step moves every factor closer to 1, i.e. closer to the unpenalised least-squares fit, which corresponds to a *smaller* lambda. Fewer iterations means heavier shrinkage, i.e. a *larger* lambda. Stating this the other way round is the single most common error on this topic, and it also makes the practical advice wrong: if a model is overfitting, you stop sooner, not later. ### Why the ordering happens at all The intuition behind the algebra is that gradient descent from zero learns the easy things first. The gradient along a direction is proportional to how much variation the data has along it, so high-variance, high-signal directions are traversed in a few steps while low-variance directions creep forward. Freeze the run at step `t` and you have a fit in which strong structure is complete and weak structure is still near its starting value — which is exactly the profile a squared penalty imposes. This is also why the whole regularization path comes free: one run passes through every effective lambda from very large (step 1) down to zero (convergence), where a penalty approach needs a separate fit per lambda. ### Where the equivalence stops being exact It is an exact statement only for this setting: squared loss, linear model, full-batch gradient descent, zero start. Several things weaken it. - **Shrinkage is toward the starting point, not toward zero.** Initialise at some non-zero vector and early stopping shrinks toward *that* vector. Sometimes that is what you want; it is not ridge. - **Other losses.** For logistic regression the correspondence is only approximate and local, because the curvature of the loss changes as the fit moves. The qualitative ordering — well-determined directions first — survives; the closed-form factors do not. - **Stochastic updates and adaptive step sizes** perturb the path, so the implied penalty is no longer a clean function of the step count. - **You cannot report the lambda.** With ridge you have a number you can log, hold fixed across retrains, and reason about. With early stopping the effective penalty depends on the learning rate, the step count, the initialisation and the data's eigen-spectrum, and it silently changes when any of them do. That is the real engineering cost of the cheaper method. ### Why interviewers ask it It is a differentiator, not a screener. Answering it well shows you understand regularization as *constraining which solutions the fit can reach*, rather than as a term you bolt onto a loss — and it explains why two knobs that look unrelated, penalty strength and run length, are often controlling the same thing.
- Does the equivalence still hold for a logistic regression fitted by gradient descent?Only approximately and locally. The closed-form shrinkage factors come from the quadratic geometry of squared loss; logistic loss has curvature that changes as the fit moves, so no clean factor exists. The qualitative statement survives — well-determined directions are fitted first, weakly determined ones last — which is why early stopping still behaves like shrinkage there.
- What changes if you start the optimizer somewhere other than zero?The shrinkage is toward the starting point, not toward zero. Early stopping from a non-zero start pulls the fit partway from that vector to the least-squares solution, which is a penalty on distance from the start rather than on coefficient size. That can be exactly what you want, but it is no longer ridge.
- If the two are equivalent, why would you ever pay for a penalty term and a lambda search?Because a lambda is a number you can log, hold fixed across retrains and reason about. The effective penalty behind early stopping depends on the learning rate, step count, initialisation and the data's spectrum, so it moves silently when any of those change. Early stopping is cheaper — one run sweeps the whole path — but far less auditable.
Filling a set of jars from one tap: the wide-mouthed jars fill almost immediately, the narrow ones barely start. Turn the tap off early and only the narrow jars are still nearly empty.
saying these in an interview costs you the question
- Says more iterations mean stronger regularization
- Claims early stopping shrinks every coefficient by the same factor
- Thinks early stopping zeroes coefficients the way an L1 penalty does
- Treats the equivalence as exact for any loss and any starting point
- Reports an effective lambda as if it were a stable setting