IMPLICIT REGULARIZATION

Estimating implicit regularization in deep learning

Information about implicit regularization is embedded in the dynamics of learning. We use gradients of the loss and a proposed regularizer to estimate its unknown parameters.

University of Pennsylvania

We often explicitly regularize models, adding constraints that can improve generalization. We also implicitly regularize through algorithmic and architectural choices, such as early stopping or dropout. Theory can characterize these effects in simplified settings, but complex networks raise the need for empirical estimation and validation.

Our task is to find a mathematically expressible regularizer such that explicitly optimizing the empirical loss augmented by that regularizer mimics an implicitly biased procedure optimizing the loss alone. Given a parametric family of regularizers, we seek to estimate its parameters.

01 — BALANCING OBJECTIVE FUNCTIONS

Regularization changes the optimum.

Regularization modifies the objective function, leading to different solutions than strictly minimizing the empirical loss. In this example, an ℓ2 penalty favors smaller weights. At the regularized minimum, its gradient counteracts the nonzero loss gradient.

Figure 1 · Loss, ℓ2 penalty, and their sum / one parameter
LossPenaltyTotal
Gradients at the selected point Arrow length uses the same scale for both gradients.
Loss gradient−1.00
+
Penalty gradient+1.00
=
Net gradient0.00

At the optimum, the slopes cancel.

L(θ)=12(θ−2)2   ·   R(θ)=λθ2

Gradient matching in multiple dimensions.

A single slope becomes a vector. At the regularized optimum, the loss and penalty gradients point in opposite directions with equal magnitude.

Figure 2 · Two parameters
∇L∇RNet
Show landscapes in both views
CONTOURS click to move the point
SURFACES drag to rotate
Point & camera controls

Arrows point uphill and share a common scale. Minima: ● loss · ▲ penalty · ◆ total. The dark circle marks the selected weights.
02 — ESTIMATING THE PENALTY

Reverse-engineering the regularization.

In Figures 1 and 2, we fixed the regularization and found the weights which minimize the regularized objective function. We can exploit the structure we saw above to reverse-engineer the regularization for a trained model: fix the learned weights θ^ and estimate the penalty parameters Λ.

A hypothetical minimum.

We often obtain weights that deviate from the strict loss minimum—for example, because we stop training before the loss has fully converged. Our key assumption is to characterize those learned weights as a minimizer of a hypothetical objective combining the empirical loss and a regularizer R(θ;Λ). The regularizer need not have been explicitly used during training.

Computing and matching gradients.

For differentiable objectives, stationarity requires the regularizer gradient to cancel the loss gradient. Both derivatives are taken with respect to the model weights θ and evaluated at the observed weights θ^:

∇θL(θ^)+∇θR(θ^;Λ)=0

Learning the regularizer. We fit a regularizer model R(θ;Λ) in which the predictive model’s weights θ^ are fixed and the regularization parameters Λ are learnable. When exact gradient matching is not possible, we minimize the mean squared error of this matching task. The training data stay fixed, and p is the number of weights.

Λ^=arg minΛ1p‖∇θL(θ^)+∇θR(θ^;Λ)‖22

In the next example, the observed weight stays fixed while we estimate the strength of the same quadratic penalty used in Figure 1.

Figure 3 · Estimating λ from an observed weight
LossPenaltyTotal
OBJECTIVE AS A FUNCTION OF θ observed θ^ stays fixed during estimation
GRADIENT-MATCHING ERROR as a function of λ
Gradients at the fixed observed weight The loss arrow stays fixed. Adjust λ to match it with the penalty arrow.
Current λ: Squared net gradient: Total minimum at θ:

The inverse calculation and its limits

In Figure 3, L(θ)=12(θ−2)2 and R(θ;λ)=λθ2 with λ≥0. Their derivatives give the residual (θ^−2)+2λθ^. For θ^≠0, minimizing its square has the closed-form solution:

λ^=max(0,2−θ^2θ^)

“Estimate λ” animates from the current guess to this exact least-squares solution; it is not a simulation of an iterative optimizer.

For 0<θ^≤2, the gradients can cancel exactly. Outside that interval, nonnegative ridge cannot explain the observed weight as an optimum: its best fit leaves a residual. At θ^=0, every λ supplies the same zero penalty gradient, so λ is unidentifiable. A fitted coefficient is an explanation within the chosen family, not evidence that this mechanism generated the weights.

Estimating regularization from training updates

An alternative perspective examines deviations along the training trajectory. At each step, architectural and algorithmic choices can make weight updates deviate from a reference path based on the loss gradient. These deviations provide another set of equations for estimating the regularization parameters, without assuming that the weights are at a minimum.

θₜReference updateObserved updateUpdatediscrepancy

For the reference update −η∇L(θt), rearranging Δθt≈−η[∇L(θt)+∇R(θt;Λ)] gives:

∇θR(θt;Λ)≈−Δθtη−∇θL(θt)

Here Δθt=θt+1−θt and η is the step size. We can fit the same coefficient across several updates, or estimate a changing coefficient at each step. Setting Δθt≈0 recovers the endpoint-matching condition.

The reference must match the question. Comparing ordinary full-batch GD with its own update −η∇L gives zero discrepancy. To study the effect of finite GD steps, the paper instead compares a discrete step with continuous gradient flow over the same time interval. Figure 5 uses endpoint matching at different iterates; it does not fit these update discrepancies.

Stationarity and identifiability.

These quadratic bowls are convex, so a zero net gradient identifies the minimum. A neural network is more complicated: gradient cancellation alone establishes stationarity, not a global minimum. Several regularizers may explain the same endpoint.

With multiple penalty terms, we fit their coefficients together: −∇L≈λ1∇R1+λ2∇R2+⋯. Each weight contributes one equation. If two penalty gradients are nearly parallel, their separate coefficients can be difficult to identify even when their sum fits well.

03 — RECOVERING EXPLICIT REGULARIZATION

Recovering an ℓ2 penalty in a neural network.

Before estimating implicit effects, we test whether the method recovers known explicit regularization. Train a small network on noisy samples of a curve. We train with an explicit ℓ2 penalty and withhold its coefficient from the estimator. The estimate uses only the weights and the gradient of the unregularized training loss. During training, this endpoint estimate may be inaccurate because the gradients have not yet reached a balance.

What counts as successful estimation?

We test two distinct claims:

  1. Recovery of hypothesized regularization. When the regularizer is known or predicted by theory, compare its estimated parameters with the known values.
  2. Recovery of the original model weights. Replace the training mechanism with the estimated explicit penalty and test whether optimizing the new objective reproduces the learned weights.

The first experiment tests recovery of a known penalty. The early-stopping example tests both claims: reproducing the weights need not uniquely identify the regularizer.

Figure 4 · Explicit ℓ2 penalty recovery1 input → 16 tanh units → 1 output · 49 parameters
● Training data┄ Target━ Network
Estimated λ^
—
True λ0.0150
Gradient explained—
Training MSE—
Net gradient norm—

Initialization seed: 7.

Model, training, and estimator

This is a simplified version of the paper’s explicit elastic-net recovery experiment. Here we estimate one ℓ2 coefficient in a small, single-input network. The paper jointly estimates smoothed ℓ1 and ℓ2 coefficients in a 200-unit ReLU network with 10 inputs, across repeated datasets and penalty settings.

We use mean squared error L=1n∑i(fθ(xi)−yi)2 and R=λ‖θ‖2, penalizing all parameters, including biases (3 × width + 1 parameters). Full-batch gradient descent runs for up to 20,000 steps. The learning rate is 0.04 × 16 / width (0.04, 0.02, or 0.01) to keep wider networks stable. The data and initialization are reproducible for each seed.

λ^=max(0,−θ⊤∇L2‖θ‖2)

This is a nonnegative least-squares projection of −∇L onto 2θ. “Gradient explained” is 1−‖∇L+2λ^θ‖2‖∇L‖2. It is a fit diagnostic, not predictive R2. Near-zero weights make the coefficient unidentifiable; a near-zero loss gradient makes the explained fraction uninformative. We display a dash for unavailable diagnostics.

For ReLU, we use a zero derivative at a kink. Tanh uses its smooth derivative, 1−tanh2(z). Finite training time and nonsmoothness can leave a residual even when the loss appears stable. This experiment demonstrates explicit-penalty recovery, not proof that an arbitrary implicit bias is ridge regularization.

04 — IMPLICIT REGULARIZATION

Estimating the regularization from stopping early.

Theory gives us a concrete example of implicit regularization: for ordinary least squares (OLS), gradient descent with a sufficiently small step size, stopped after a finite number of steps from zero initialization, has the same solution as an explicitly regularized regression. The equivalent penalty is quadratic, R(θ)=θ⊤Λ(t)θ, with a closed-form matrix Λ(t) determined by the data, step size, and stopping time. This matrix is the target for gradient matching.

We ask two different questions: can we recover that theoretical matrix, and can an estimated penalty recover the original model weights? A diagonal estimate from one endpoint can recover the weights while differing from theory. A full symmetric estimate uses weights from several independently trained models to recover the matrix. A single ridge coefficient provides a heuristic summary of how regularization decays over training.

The theoretical quadratic penalty and closed-form OLS solution

Let H=X⊤Xn=Vdiag(hi)V⊤ and use the loss L(θ)=‖Xθ−y‖22n. Full-batch gradient descent starts at zero with step size η satisfying 0<ηhi<1. At step t≥1, its weights minimize L(θ)+θ⊤Λ(t)θ, where

Λ(t)=12Vdiag[hi(1−ηhi)t1−(1−ηhi)t]V⊤

The eigenvectors give the penalty’s directions, and its eigenvalues decrease over training. The matrix is generally not diagonal in the original input coordinates. The factor ½ reflects the half-MSE loss convention used here; the paper writes its theoretical penalty with the loss ‖Xθ−y‖2/n.

For any estimated symmetric matrix Λ^, the explicit solution is θ^R=(H+2Λ^)−1X⊤yn, provided H+2Λ^ is positive definite. We solve this system independently to test weight recovery. The estimator receives weights and loss gradients, not the theoretical matrix or its eigenvectors.

Figure 5 · Implicit regularization from early stopping10 weights · 160 observations · full-batch GD

Recovering the regularization matrix.

Write the quadratic penalty as R(θ)=θ⊤Λθ. Each square below is an entry Λij, in the original ten input coordinates. Diagonal entries penalize individual weights; off-diagonal entries couple pairs of weights. The theoretical matrix comes from the known early-stopping formula; the estimate comes from matching gradients. With one ridge coefficient, the estimated matrix is λ^I.

THEORETICAL Λ
ESTIMATED Λ^
DIFFERENCE Λ^−Λ

White in the difference map indicates agreement.

DOES THE PENALTY RECOVER THE WEIGHTS?
□ One model weight┄ Exact agreement

Each point compares one stopped weight with its explicitly regularized solution. The dashed diagonal indicates exact recovery.

SCALAR RIDGE SUMMARY OVER TRAINING

Absolute matrix error: Weight recovery error ‖θ^−θ^R‖2: Net gradient norm:

Training uses no explicit penalty. Recovered weights are computed separately with the estimated penalty, using the first training endpoint.
Estimation methods and relation to the paper

Absolute matrix error is the Frobenius norm of the difference between the estimated and theoretical matrices. Zero means exact agreement. Gradient matching can be exact even when the matrix is not identified; agreement with theory and recovery of the weights test different claims.

These comparisons correspond to Figure 4 of the paper: full-matrix recovery in panel B, diagonal estimation in panel C, and a scalar ridge summary in panel E. The curvature ratio is the Hessian condition number: the largest curvature divided by the smallest.

We use 160 observations and 10 inputs; the paper uses 1000 observations. We construct X with Hessian eigenvalues ranging from 2 to 2/κ, use coefficient seed 7 and Gaussian noise with standard deviation 0.3, and run full-batch GD with η=0.2. Changing κ rebuilds the design. All endpoints use the same X and the same selected training step; only the true coefficients and noise are resampled.

Diagonal: fit ten signed coefficients in the original input coordinates, Λ^ii=−∂iL2θ^i. These are not coefficients in the Hessian eigenbasis. A zero weight makes its coefficient unidentifiable. Even with an exact gradient match, a unique minimum requires H+2Λ^ to be positive definite; the display checks this condition.

Full symmetric: fit all 55 independent entries by minimizing ∑k‖2Λ^θ^k+∇Lk‖2 over symmetric matrices. If the system is underdetermined, we select the solution with smallest Frobenius norm. Ten linearly independent endpoints identify the matrix; fewer leave unobserved directions. No theoretical eigenvectors are supplied. The endpoints share a stopping time; the paper also studies estimation across different stopping times.

Scalar ridge: fit Λ^=λ^I, using λ^=max(0,−θ^⊤∇L2‖θ^‖2). The right plot always shows this separate scalar summary, so it has the same meaning under every matrix selection. Its decline need not imply that scalar ridge recovers the full matrix or the stopped weights.

The matrix heatmaps compare against the independent theoretical formula above. Random initialization changes the starting weights for every endpoint while keeping the data fixed; the zero-start theoretical comparison is hidden in that case.

Estimating regularization from neural-network training dynamics.

Early stopping characterizes a selected endpoint. We can also estimate regularization from deviations along a training trajectory. Barrett and Dherin predict that, for a smooth loss and sufficiently small steps, discrete gradient descent follows approximately the continuous gradient flow of a modified objective with a penalty on the squared loss-gradient norm:

R(θ)=λp‖∇θL(θ)‖2,λ=ηp4

Here η is the step size and p is the number of model parameters. In the paper, we estimate this coefficient from the difference between discrete gradient-descent steps and continuous gradient flow, using five-hidden-layer tanh networks trained on MNIST. The estimates closely track the theoretical coefficient across network sizes and step sizes.

Log-log plot comparing estimated lambda on the horizontal axis with theoretical eta p over four on the vertical axis. Points for different network sizes lie close to the dotted equality line.
Figure 6 · Recovery from trajectory deviations. Estimated coefficient (horizontal) versus theoretical coefficient (vertical); the dotted line marks equality. Colors distinguish network sizes. Extracted from the right panel of Figure 6 in the paper. This is a calibration test of the estimator against a known theoretical prediction, not evidence that the penalty alone explains test accuracy.
How the trajectory comparison is computed

At selected trained checkpoints, we take five full-batch probe steps. For each step, the reference is continuous gradient flow over the same elapsed time, numerically approximated using fourth-order Runge–Kutta integration. The estimator fits the discrepancy using Hessian–gradient products. Comparing a full-batch step with its own linearized loss-gradient update would give zero discrepancy; the continuous-flow reference is essential.

The networks have hidden widths from 50 to 1,600. Checkpoints are selected by validation accuracy among those reaching at least 90% training accuracy. Probe gradients use a fixed subset of 2,048 training examples. The paper gives the full protocol and approximation assumptions.

EVALUATING ESTIMATED REGULARIZATION

What the estimates establish.

Gradient matching can recover known explicit penalties and theoretically predicted implicit regularization. Recovering a regularizer’s parameters and reproducing the original model weights are distinct tests: several regularizers may explain the same endpoint.

The paper’s dropout experiments illustrate the limits of a proposed regularizer family. Dropout randomly suppresses hidden units during training. Fitting a scalar ridge penalty reveals variation in the ridge-aligned component across dropout rates and architectures, but explains only a small fraction of the loss gradient. Replacing dropout with that penalty does not reproduce the original test performance.

These experiments provide proof of concept. Extending the approach to larger and more complex systems requires informative candidate regularizers, enough independent gradient equations, and controlled ablations to separate interacting training mechanisms. Even when a candidate captures only part of the effect, its estimate can help characterize how training choices change learning dynamics.

Read the paper on arXiv ↗