7 routes42 sections324 units

Unit 3.4 · about 4 h

188 / 324

Regularization: dropout, label smoothing, augmentation and weight decay

Regularization trades training fit for held-out behavior. Each method changes a different part of the objective or the data, and conflating them leads to double-counted or cancelled effects.

  • explain
  • derive

You can now

  • Derive the SGD weight-decay update from the L2-penalized objective and state exactly where the Adam equivalence breaks.
  • Explain dropout scaling, label-smoothing targets and augmentation policy as separate generalization levers.
  • Choose which parameters escape decay and defend the choice.

Covers

  • Dropout, label smoothing and data augmentation
  • Weight decay versus an L2 penalty

Study, in this order

5 steps

  1. Explicit and implicit regularization
    Understanding Deep Learning - fitting, gradients and regularization

    Chapter 9, Sections 9.1 through 9.2 (pp. 138 to 143): L2 regularization and implicit regularization in gradient descent and SGD

  2. Dropout, label smoothing and augmentation
    Understanding Deep Learning - fitting, gradients and regularization

    Chapter 9, Sections 9.3.3, 9.3.4 and 9.3.8 (pp. 147 to 154): dropout, applying noise with label smoothing, and augmentation

    Depth · Read Sections 9.3.3, 9.3.4 and 9.3.8 only. Skip Bayesian inference, transfer learning and self-supervised learning.

  3. Dropout scaling and behavior
    D2L - optimization and regularization slice

    Dropout in Practice and Implementation from Scratch: inverted scaling and the train and eval split

  4. Weight decay under SGD
    D2L - optimization and regularization slice

    Norms and Weight Decay and Implementation from Scratch: penalized objective, SGD shrinkage update, and bias exclusion

  5. Decoupled weight decay
    PyTorch torch.optim.AdamW reference

    AdamW algorithm box: the decoupled decay line and its defaults

Focus on

  • L2 adds \((\lambda/2)\|w\|^2\) to the loss, and SGD turns it into per-step shrinkage \((1 - \eta\lambda)\). The \(1/2\) cancels the square's derivative.
  • Adam normalizes the whole gradient, L2 term included, by its adaptive denominator, so the penalty no longer shrinks weights by a fixed fraction. AdamW applies the shrinkage outside the adaptive update.
  • Inverted dropout divides kept activations by \((1-p)\) during training, so test time needs no scaling and the expectation stays exact.
  • Label smoothing replaces hard targets with a blend of the true class and uniform. Augmentation enlarges the data, but its transforms must not change the label.

Reproduce closed-book

Closed-book, derive \(w \leftarrow (1 - \eta\lambda)w - \eta\text{grad}\) from the penalized loss. Then write the AdamW two-line update, decoupled decay plus bias-corrected adaptive step, and state the default decay 0.01.

Traps

  • Adding L2 to Adam and calling it weight decay. The adaptive denominator rescales the penalty per coordinate; use the optimizer's decoupled decay instead.
  • Decaying biases and normalization scales by default. They hold offsets, not feature weights; D2L excludes the bias from the penalty, and the same argument covers normalization scales.
  • Reading UDL's implicit-regularization equations as exact. The modified loss is a first-order approximation in the step size; it explains tendencies, not exact trajectories.

Practice

D2L Dropout: Exercises

Exercises: layer-probability swaps, the dropout versus no-dropout comparison, activation variance plots, and the dropout plus weight-decay interaction

D2L Weight Decay: Exercises

Exercises: the \(\lambda\) sweep on training and validation accuracy and the validation-optimum question

TrenTorch: Label Smoothing

Implement smooth_labels(one_hot, smoothing, num_classes) for one target and for a batch

The true class ends at \(1 - \text{smoothing} + \text{smoothing}/K\) and every other class at \(\text{smoothing}/K\), the same targets torch.nn.CrossEntropyLoss(label_smoothing=...) uses.

Self-test

  1. Loss \(L(w)\) plus \((\lambda/2)\|w\|^2\) under SGD with step \(\eta\). What is the update?

  2. Why does the same penalty fail to shrink weights by a fixed fraction under Adam?

  3. Dropout \(p\) 0.3, activation 10. What values can the next layer see during training, and what is the mean?

  4. 10 classes, smoothing 0.1. What target values do the true class and each other class get?

Completion criterion

Stop when

You write both the SGD shrinkage update and the AdamW decoupled update without notes, and your \(\lambda\) sweep on the D2L regression task shows training loss rising with \(\lambda\) while validation loss first falls, then rises.

Mark passed, then open 3.5 Only mark this when you can do it without notes.

Leads to

Resources for this unit

  • Understanding Deep Learning - fitting, gradients and regularization
    Simon J. D. Princeprimarytheory
    Use Chapters 6-9 and targeted parts of Chapter 20 for optimization, initialization, measurement, regularization and why training works. Re-derive the update rules you keep in the trainer.
  • D2L - optimization and regularization slice
    D2L authorsrequiredimplementation
    Use MLP implementation, dropout, deep generalization, numerical stability, optimization introduction, SGD, minibatch SGD, momentum, AdaGrad, RMSProp, Adam and learning-rate scheduler. Implement momentum, AdamW, initialization, dropout, one normalization, clipping and one schedule.
  • PyTorch torch.optim.AdamW reference
    PyTorchreferencereference
    Read the AdamW algorithm box for the decoupled weight-decay step, the bias-corrected moments and the defaults, and follow the Decoupled Weight Decay Regularization link for the argument.

Also in this section

Quick find

Search Michi

Type to search every route, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels