Skip to content
AI 知识地图 0.18 · 2026-07-30
关于与纠错文字目录 / Search
Understanding the principles

Regularization: Constraining How Models Learn with Interpretable Preferences

Starting from L2/L1, AdamW, Dropout, data augmentation, and early stopping, understand how four types of constraints—on parameters, representations, data, and training paths—change generalization, instead of treating regularization as a one-size-fits-all knob.

Core idea Regularization is not simply making weights smaller; it adds inductive preferences about which solutions are more credible to the learning process: preferences for small parameters, sparse representations, solutions stable to reasonable perturbations, or solutions that appear earlier. It usually sacrifices some training fit in exchange for lower unknown risk; if the preference does not match the task, it can also cause underfitting.
After reading this page, you should be able to answer:
  • Why should you proactively constrain a model when it can already fit the training set?
  • How do L2, L1, and decoupled weight decay each change parameter updates?
  • Why can Dropout be viewed as random subnetworks, and why can't training and inference use the same operation?
  • How does data augmentation encode "invariance" into training, and when does it instead inject incorrect labels?
  • How can you use training/validation curves together to select regularization strength without mistaking optimization failure for overfitting?
Continuing the simulation experiment from the overfitting pageA 15th-degree polynomial fits 24 noisy training points to an MSE of 0.01, while the validation MSE is 1.47. Regularization does not remove this 15th-degree expressive capacity; instead, it makes the "violent oscillations that require large, mutually canceling coefficients" incur a cost, thereby biasing toward smoother curves.

1Why ask “which fit is preferred” after “fitting is possible”?Motivation

Many models can reduce training error to near zero; how should the optimizer choose among the many solutions?

Limited data are usually insufficient to determine a unique function. A curve passing through the same training points can be smooth or oscillate wildly between points; neural networks also have many solutions with similar training loss but different parameters, robustness, and unknown performance. Regularization adds a preference to the selection process, making some solutions easier for the optimizer to find or giving them a lower total objective.

This preference is not a truth that comes for free. Whether small weights, sparsity, image translation invariance, or early stopping is reasonable depends on the task. Too much regularization will suppress true complexity and make both training and validation worse.

2How the penalty form writes preferences into the objective functionMath

How does “Don’t let the model be too complex” become a scalar the optimizer can use?

Jtotal(θ)=Jdata(θ)+λΩ(θ)

J_data requires fitting the samples, Ω measures undesirable parameters or behavior, λ controls the tradeoff. It can also be understood as a constrained problem: when the training error is acceptable, limit complexity, or fit as well as possible within a complexity budget.

Regularization termGeometric preferenceCommon effectNote
L2:||θ||²Continuously shrinks each dimensionSuppresses large weights, yielding smoother solutionsTypically does not produce exact zeros
L1:||θ||₁Constraint region with sharp cornersMany parameters become zero, producing sparsitySelection among correlated features may be unstable
Group sparsityPenalizes entire parameter groups jointlyRemoves channels, feature groupsGrouping must have task meaning

3How L2 pulls large parameters back at every stepNumerical example

After adding the regularization term, what exactly is added to the gradient?

If we use Ω(w)=½w², then the regularization gradient is λw. Suppose currently w=4, data gradient g_data=−0.4,λ=0.05, learning rate 0.1:

PartCalculationResult
Gradient the data wantsg_data−0.4 (pushes w upward)
L2 gradientλw=0.05×4+0.2 (pulls toward 0)
Total gradient−0.4+0.2−0.2
Updatew←4−0.1×(−0.2)4.02

The parameter still increases along the data direction, but the magnitude drops from 0.04 without regularization to 0.02. Regularization does not force it smaller every time; rather, it competes between the data gradient and the preference.

4Why AdamW decouples weight decay from the gradientDisambiguation

Why are L2 regularization and “shrinking the weights a bit at each step” no longer equivalent in Adam?

With ordinary SGD, when all parameters use the same scale, the L2 gradient and weight decay are closely related; Adam uses historical squared gradients to apply per-parameter scaling to the total gradient, including λθ included in the total gradient for per-parameter scaling, causing the effective regularization strength to vary across parameters. AdamW, outside the optimization update, independently performs θ←(1−ηλ)θ, making the decay more interpretable.

The same name does not mean the same implementation. The training configuration's weight_decay may indicate either coupled L2 or AdamW-style decoupled weight decay; you must check the actual optimizer implementation. Whether biases and normalization parameters are decayed should also be clearly recorded.

5Why Dropout Is Like Training Many Subnetworks with Shared ParametersRepresentation Constraint

Randomly zeroing activations—why is this not simply destroying information?

During training, each activation with probability p is masked, and the remaining activations are usually divided by 1−p(inverted dropout), preserving the expected scale. Each batch amounts to sampling a subnetwork, and parameters must work under many combinations of missing units, making it hard to rely on fixed co-adaptation.

One subnetwork sampleAnother sample

Scroll horizontally to view the full diagram on small screens.

Masked units change every batch; at inference the complete network is used, so the scale adopted must match the training convention.

A dropout rate that is too high will lose real signal; with large datasets, strong data augmentation, normalization, and existing weight decay, the additional benefit may be small. Incorrectly switching between training and evaluation modes will cause systematic scale bias.

6How does data augmentation write “changes that should not change the answer” into trainingData Preference

Why is changing the input but keeping the label also a form of regularization?

Augmentation expands the local neighborhood of each sample, telling the model that certain changes should not affect the output. For example, small translations, crops, or color perturbations in natural object classification force the model to rely less on fixed pixel positions. Text back-translation, paraphrasing, and audio noise can play similar roles.

AugmentationImplicit invarianceScenarios that may corrupt the label
Horizontal flipLeft-right orientation is unimportantText, traffic signs, medical left/right sides
Random cropLocal parts still represent the wholeKey targets are cropped out
ParaphrasingWording changes do not alter intentLegal, negation, numerical detail changes
Adding noiseSmall perturbations do not alter semanticsWeak signals are themselves the basis of the label

Augmentation is not “the more data, the better”; it is a statement about task symmetries and invariances. If the statement is wrong, it will consistently teach the model the wrong thing.

7Why early stopping is equivalent to limiting the optimization path lengthProcess constraint

Why can early stopping improve generalization even without modifying the model or the loss?

Early in training, the model typically first learns large-scale, recurring patterns, and only as optimization continues does it gradually fit noise and individual samples. Early stopping uses the validation set to select a checkpoint on the path, limiting the model from continuing to descend along the training empirical risk. In linear problems, it is related to certain parameter penalties; in deep networks it should be understood more as process regularization that depends on the optimization trajectory.

If the patience window is too short, validation noise will be mistaken for a trend; if too long, it may overshoot the optimal point. You must save the best checkpoint, rather than judging only at the final step whether it has “already overfit.”

8How Regularization Strength Produces the Bias–Variance TradeoffValidation Curve

Why does validation error often first decrease and then increase as regularization is gradually strengthened from zero?

Training errorValidation errorCandidate strengthRegularization strength λ

Scroll horizontally to view the full diagram on small screens.

Training error usually rises as regularization increases; the lowest point of validation error is the candidate, not the minimum training loss.

Weak regularization keeps low bias but may have high variance; strong regularization reduces sensitivity to sample randomness but may suppress real structure. Curve position varies with data size, model, optimizer, and training duration; cannot take a once-found λ as a permanent constant.

9Why Multiple Regularizers Interact Rather than Simply Adding UpRecipe

When you already have large-scale augmentation, weight decay, and early stopping, what happens if you add Dropout?

Different techniques may constrain the same failure path or may be complementary. Strong augmentation already creates many input variations; adding Dropout to further disrupt representations may lead to underfitting; batch noise and a smaller learning rate alter implicit regularization; BatchNorm's statistical noise is also related to batch size. Regularization must be viewed as a recipe rather than independent switches.

ObservationMore likely stateNext step
Training good, validation poorOverfitting or leakage/distribution problemsFirst fix the data split, then strengthen each regularizer in turn.
Training and validation both poorUnderfitting, optimization, or objective problemReduce regularization, check capacity and learning rate.
Training worsens, validation improvesMay be effective regularizationConfirm slices and final task metrics.
Overall good, key slices poorAverages mask insufficient coverage.Add data/reweight, don't just tune λ.

10How to design an attributable regularization experimentWorked example

If you change augmentation, dropout, weight decay, and the number of training epochs all at once, why can't you draw reliable conclusions?

  1. First, freeze the split:Deduplicate by entity/time and keep a test set that was not used for selection.
  2. Establish a no-regularization or weak-regularization baseline:Record training, validation, slices, and calibration.
  3. Change only one type of mechanism at a time:Parameter penalty, representation noise, data augmentation, or early stopping.
  4. Sweep strengths rather than only trying default values:At least cover the range from under-constrained to clearly underfitting.
  5. Fix the budget and random seed groups:Avoid attributing changes in training steps or random fluctuations to regularization.
  6. Report training–validation co-variation:Validation improvement accompanied by slightly worse training is what matches typical regularization evidence.
  7. When combining, run ablations:Remove any single component to confirm its contribution and interactions.

11Connecting the Whole Causal ChainSynthesis

From limited samples to more trustworthy unknown performance, where does regularization impose preferences?

  1. A finite training set permits many solutions with similar empirical risk.
  2. Some of these solutions depend on noise, huge parameters, or fragile co-adaptation.
  3. Parameter regularization changes the objective geometry, biasing toward small or sparse parameters.
  4. Dropout changes representation paths, and data augmentation declares input invariance.
  5. Early stopping limits the optimization path that continues to fit sample contingencies.
  6. These preferences increase training error but can reduce unknown risk.
  7. Independent validation selects the mechanism and strength, and slice checks who benefits and who is harmed.
  8. After data, model, or optimization recipe changes, reselect; you cannot inherit old defaults.

12Common MisconceptionsDisambiguation

MisconceptionMore Accurate Statement
Regularization is just L2Parameter penalties, representation noise, data augmentation, and training paths can all regularize.
The stronger the regularization, the less likely to overfit.If too strong, it will underfit, and true patterns will also be suppressed.
During inference, Dropout should also randomly turn off units.The standard practice uses the full network at inference and matches the training scale.
Data augmentation always preserves labels.Only transformations that conform to task invariance are safe.
Regularization can fix data leakage.Leakage contaminates validation evidence; you can only rebuild the split and evaluation.

13Check whether you really understandSelf-test

  1. Why can the same training loss correspond to multiple solutions with different generalization?
  2. In the numerical example, why does L2 only weaken the data push, without making w smaller?
  3. What is the core difference between coupled L2 in Adam and decoupled weight decay in AdamW?
  4. Why might horizontal flip augmentation be harmful for text-recognition images?
  5. After adding Dropout, both training and validation get worse; how would you decide the next step?
Reference answers
  1. Finite samples cannot uniquely constrain the function; the model can achieve similar empirical risk through smooth regular patterns or fragile noise paths.
  2. The data gradient's pushing force to increase is still greater than L2's pulling-back force; regularization only changes the total gradient from −0.4 to −0.2.
  3. Coupled L2 enters the gradient and is scaled per parameter by Adam; AdamW uniformly shrinks parameters outside the gradient update.
  4. Flipping changes character orientation or meaning, violates label invariance, and is equivalent to injecting incorrect supervision.
  5. First confirm it is not insufficient optimization; lower Dropout/other regularization, compare training capacity, and use ablation to determine whether it is already underfitting.

14Concept Dependencies and Further LearningPath

DirectionNext ReadKey Question
Why constraints are neededOverfittingHow are unknown risk and training risk separated?
How is weight decay applied?Optimizers and Learning Rate SchedulesHow do AdamW and scheduling change effective regularization?
Boundaries of data variationTraining Data GovernanceHow are augmentation, repetition, and provenance tracked?
More robust representationsNormalizationAre stabilizing scale and limiting generalization the same problem?
How to choose the strength?Model EvaluationHow are slices, confidence intervals, and test discipline established?
Passing Criteria You can explicitly assign a type of regularization to parameters, representations, data, or training path, and explain what invariance it assumes, which part of the update it changes, and what validation evidence is used to judge whether the strength is appropriate.
Sources and adaptation notes

The diagrams, numerical examples, experimental workflow, and comparison tables are all original content created by this project.

Date accessed: 2026-07-22