Seyed Masoud Hosseini · Overview · Study log · Weekly summaries · Ideas · Search · Transcript · RSS feed
Deep Learning Systems · Lecture 10 of 25 · 1:19:30
Lecture 9: Normalization and Regularization
Study guide
What this lecture covers
The lecture asks why deep networks are hard to train reliably and what tricks make them easier. It follows on from earlier lectures on building a neural network library, and shows that initialization alone does not solve training instability: badly scaled weights either blow up into NaN values or make no progress at all, even after many gradient steps.
The lecture then introduces normalization layers (layer norm and batch norm) as an explicit fix for unstable activations, and regularization (L2 weight decay and dropout) as a way to keep overparameterized networks from overfitting. It closes with a case study on batch norm showing that even widely used techniques are not fully explained theoretically. After watching, you should be able to explain what layer norm and batch norm compute, implement L2 regularization and dropout correctly with gradient-based optimizers, and describe why these techniques interact with initialization and optimization.
Key ideas
- Initialization variance matters: for ReLU networks, weights initialized with variance
2/nkeep activation and gradient norms stable across depth; slightly larger or smaller variances cause exploding or vanishing behavior in deep networks. - Layer norm: normalizes each example's activation vector to mean 0 and variance 1 at every layer, which fixes exploding/vanishing activations but can make plain fully connected networks harder to optimize.
- Batch norm: normalizes each feature (column) across the examples in a mini-batch rather than each example (row); widely used but makes predictions for one example depend on the other examples in its batch during training.
- Running statistics at test time: batch norm tracks exponential moving averages of the mean and variance during training and uses those, not batch statistics, at test time.
- L2 regularization (weight decay): adds
lambda/2 * sum of squared weight normsto the loss, which shrinks weights toward zero on every update; it is usually implemented as a property of the optimizer, not the loss. - Dropout: randomly zeroes each activation with probability
pduring training and rescales the rest by1/(1-p); best understood as a stochastic approximation of the layer's activations, similar to how SGD approximates gradient descent using mini-batches. - Implicit vs explicit regularization: SGD itself, combined with a given weight initialization, implicitly limits which functions a network can reach, separate from explicit regularizers like weight decay or dropout.
- Theoretical uncertainty: batch norm was originally explained as reducing "internal covariate shift," but later papers dispute this and instead point to smoother optimization landscapes or robustness to distribution shift, and no explanation is fully settled.
Walkthrough
Why initialization alone is not enough (1:01)
The lecture revisits weight initialization with variance c/n and shows, using a 50-layer network on MNIST, that only c=2 keeps activation and gradient norms roughly constant across depth. Smaller variance causes activations to shrink toward zero and training to stall; larger variance causes activations and gradients to blow up, producing NaN losses. A surprising observation follows: after training, the norm of the weights at each layer is nearly indistinguishable from their value at initialization, even though the network trains successfully — initialization has a lasting effect on a deep network's behavior.
Layer normalization (12:13)
Rather than relying on careful initialization, the lecture proposes adding a layer that forces each example's activations to have mean 0 and variance 1, computed empirically and divided by the standard deviation plus a small epsilon to avoid division by zero. This stabilizes activation and gradient norms regardless of initialization and is standard in transformer architectures, but can make plain fully connected networks harder to train because it removes potentially useful information carried in the relative norms of different examples.
Batch normalization (23:45)
Viewing activations as a matrix with examples as rows, batch norm normalizes columns (features) across a mini-batch instead of rows (examples). This preserves per-example norm differences while still stabilizing the network, but introduces a dependency between examples in the same batch during training. To avoid using batch-dependent statistics at inference, the lecture derives the exponential-moving-average update for running mean and variance, which is used instead of batch statistics at test time.
Regularization and overparameterization (34:02)
The lecture explains that deep networks are typically overparameterized — they have more weights than training examples and can fit the training set almost exactly — which classically risks overfitting. It distinguishes implicit regularization (for example, SGD with a given initialization only reaches a limited set of functions) from explicit regularization, which the rest of the lecture focuses on.
L2 regularization / weight decay (40:17)
L2 regularization adds a penalty on the squared norm of the weights to the loss, on the reasoning that smaller weights produce smoother, less complex functions. Working through the gradient of this augmented objective shows that the resulting update multiplies the old weights by a factor slightly less than 1 before each gradient step, which is why it is called weight decay. The lecture notes this is normally implemented inside the optimizer (applied to the gradient) rather than as a separate loss term, and cautions that its real effect on function complexity in deep networks is uncertain.
Dropout (55:38)
Dropout randomly zeroes a fraction p of each layer's activations during training and rescales the remaining ones by 1/(1-p) to preserve their expected scale; it is applied only during training, not at test time. Rather than framing dropout as forcing robustness to missing features, the lecture presents it as a stochastic approximation of a layer's exact computation, directly analogous to how mini-batch SGD approximates full-batch gradient descent.
Interaction of the techniques and open questions about batch norm (1:04:16)
The lecture reviews the many design choices in training a deep network (optimizer, initialization, normalization, regularization) and warns against exhaustive grid search. It then traces the history of batch norm as a case study: the original paper attributed its benefit to reducing "internal covariate shift," a later paper argued instead that it smooths the optimization landscape, and still later work found no evidence that batch norm affects smoothness at all. It closes by noting that batch norm has since found new use as a way to make classifiers more robust under distribution shift, illustrating that even standard, heavily used techniques are not fully understood theoretically.
Before you watch
- Be comfortable with how deep networks compute forward and backward passes, and how gradient descent updates weights, from earlier lectures in this course.
- Know how weight initialization variance is chosen for ReLU networks, covered in an earlier lecture.
- Basic familiarity with mean, variance and the Frobenius norm of a matrix will help with the normalization and L2 regularization derivations.
Check your understanding
- Why does a weight initialization of
1/ncause training to stall, while3/ncauses the loss to become NaN, for a deep ReLU network? - What is the difference between what layer norm normalizes and what batch norm normalizes, and why does that difference matter at test time?
- Derive, in words, why the L2-regularized gradient update multiplies the weights by a factor less than 1 at each step.
- Why is dropout described in this lecture as a stochastic approximation rather than as forcing robustness to missing activations?
- What competing explanations does the lecture give for why batch norm improves training, and what does their disagreement suggest about our understanding of deep learning tricks?
Vocabulary
- normalization (noun)
- Adjusting values so they have a standard scale, such as mean 0 and variance 1.
Normalization keeps activations from becoming too large or too small. - regularization (noun)
- A technique that discourages a model from fitting the training data too closely.
L2 regularization and dropout are both forms of regularization. - stall (verb)
- To stop making progress.
Training can stall if weights start too small. - blow up (phrasal verb)
- To grow extremely large very suddenly.
Bad initialization can make the loss blow up to NaN. - indistinguishable (adjective)
- Impossible to tell apart from something else.
The trained weights were nearly indistinguishable from their initial values. - layer norm (noun)
- A technique that normalizes each example's activations to mean 0 and variance 1.
Layer norm is standard in transformer architectures. - empirically (adverb)
- Based on observed data rather than theory alone.
The mean and variance are computed empirically. - standard deviation (noun)
- A measure of how spread out a set of numbers is, related to variance.
We divide by the standard deviation plus a small epsilon. - batch norm (noun)
- A technique that normalizes each feature across all examples in a mini-batch.
Batch norm normalizes columns instead of rows. - dependency (noun)
- A situation where one thing relies on or is affected by another.
Batch norm introduces a dependency between examples in a batch. - running statistics (noun)
- Averages updated gradually over training and kept for later use.
Running statistics are used instead of batch statistics at test time. - inference (noun)
- The stage where a trained model makes predictions, as opposed to training.
At inference time, batch norm uses the running average. - overparameterized (adjective)
- Having far more parameters than needed to fit the data.
Deep networks are often overparameterized. - overfitting (noun)
- When a model fits training data too closely and fails to generalize.
Regularization is used to reduce overfitting. - implicit (adjective)
- Present without being directly stated or built in on purpose.
SGD provides implicit regularization. - explicit (adjective)
- Stated directly and deliberately included.
Weight decay is an explicit form of regularization. - weight decay (noun)
- A method that slightly shrinks weights toward zero at every update.
L2 regularization is usually implemented as weight decay. - penalty (noun)
- An extra cost added to discourage certain behavior.
L2 regularization adds a penalty on large weights. - dropout (noun)
- A technique that randomly turns off some activations during training.
Dropout zeroes activations with probability p. - rescale (verb)
- To adjust the size of values back to their expected range.
Dropout rescales the remaining activations. - stochastic approximation (noun)
- An estimate based on randomness rather than an exact calculation.
Dropout is described as a stochastic approximation of a layer. - grid search (noun)
- Trying every combination of settings to find the best one.
The lecture warns against exhaustive grid search. - covariate shift (noun)
- A change in the distribution of input data seen by a layer during training.
Batch norm was first explained as reducing internal covariate shift. - distribution shift (noun)
- A difference between the data a model was trained on and the data it sees later.
Batch norm can improve robustness to distribution shift. - settled (adjective)
- Fully agreed upon and no longer in dispute.
No explanation for batch norm is fully settled.
Chapters
- 0:00 Introduction
- 1:07 Intialization vs. optimization
- 12:22 Normalization
- 13:51 Layer normalization
- 19:12 LayerNorm illustration
- 23:05 Batch normalization
- 27:29 Minibatch dependence
- 34:03 Regularization of deep networks
- 36:34 Regularization
- 40:27 L2 regularization a.k.a. weight decay
- 53:27 Caveats of L2 regularization
- 55:38 Dropout
- 58:55 Dropout as stochastic approximation
- 1:04:36 Many solution ... many more questions
- 1:06:44 BatchNorm: An illustrative example
- 1:12:36 BatchNorm: Other benefits?
- 1:15:46 The ultimate takeaway message
From the YouTube description
This lecture gives an overview of normalization layers in deep networks (such as LayerNorm and BatchNorm). It also discusses methods for regularizing networks, include L2 regularization and Dropout. Finally, we cover some challenges with the interaction of optimization, initialization, normalization, and regularization.
Sign up for the course for free at https://dlsyscourse.org.
Contents:
00:00:00 - Introduction
00:01:07 - Intialization vs. optimization
00:12:22 - Normalization
00:13:51 - Layer normalization
00:19:12 - LayerNorm illustration
00:23:05 - Batch normalization
00:27:29 - Minibatch dependence
00:34:03 - Regularization of deep networks
00:36:34 - Regularization
00:40:27 - L2 regularization a.k.a. weight decay
00:53:27 - Caveats of L2 regularization
00:55:38 - Dropout
00:58:55 - Dropout as stochastic approximation
01:04:36 - Many solution ... many more questions
01:06:44 - BatchNorm: An illustrative example
01:12:36 - BatchNorm: Other benefits?
01:15:46 - The ultimate takeaway message
← Lecture 8: Neural Network Library Implementation · Lecture 10: Convolutional Networks →
