Why Does Batch Norm Work? (C2W3L06)

DeepLearningAI · Beginner ·📐 ML Fundamentals ·9y ago

Key Takeaways

Batch normalization is explained in detail, including its benefits and how it works in deep learning models, specifically within the context of the Deep Learning Specialization course by DeepLearningAI.

Full Transcript

so why does that song work just one reason you've seen how normalizing the input features the X's to mean 0 and variance 1 how that can speed up learning so rather than having some features they range from 0 to 1 and some from one to a thousand by normalizing all the features input features X to take on a similar range of values that can speed up learning so one intuition behind why passional works is this is doing a similar thing but for the values in your hidden unions and not just for your input layer now this is just a partial picture for what - norm is doing there are a couple further intuitions that will help you gain a deeper understanding of what batch tom is doing let's take a look at those in this video a second reason why batch norm works is it makes wait later or deeper than your network say the way so layer 10 more robust to changes to ways in earlier layers of the neural network say in their one to explain what I mean let's look at this motivating example let's say you're training a network maybe a shallow Network like legit regression or maybe a neural network maybe run maybe a shallow Network languages Russian or maybe a deeper network on our famous cat detection sauce but let's say that you've trained your datasets on all images of black cats if you now try to apply this network to data with colored cats where the positive examples are not just black cats like on the left but the colored cats like on the right then your Casas might not do very well so in pictures if your training set look like this where you have positive examples here and negative examples here but you were to try to generalize it to data set where we will posit examples are here and the negative examples are here then you might not expect a model trained on the data on the left to do very well on the data on the right even though you know there might be the same function it actually works well but you wouldn't expect your learning algorithm to discover that green decision boundaries just looking at the data on the left so this idea of your data distribution changing goes by the somewhat fancy name covariant shift and the idea is that if you learn some XY mapping if the distribution of X changes then you might need to retrain your learning algorithm and this is true even if the function the ground true function mapping from X to Y remains unchanged which it is in this example because the ground root function is is this picture of cattle not and they need to retrain your function becomes even more acute or becomes even worse if the ground true function shifts as well so how does this problem of covariant apply to a neural network consider a deep network like this and let's look at the learning process from the perspective of this hidden layer the third hidden layer so this network has to learn the parameters W 3 and B 3 and from the perspective of the third hidden layer it gets some set of values from the earlier leaders and then it has to do some stuff to hopefully make the output Y hat close to the ground true value Y so let me cover up the nodes on the left for a second so from the perspective of this third thin layer it gets some values let's call them a 2 1 a 2 2 a 2 3 and a 2 4 but these values might as well be features x1 x2 x3 x4 and the job of the 13 layer is to take these values and find a way to map them to my hat so you can imagine doing gradient descent so that these parameters W 3 P 3 as well as maybe W 4 B 4 and even w 5 B 5 maybe trying to learn those parameters so the network does a good job not being from the values I drew in black on the left to the output values why I had but now let's uncover the left of the network again the network is also adapting parameters W 2 B 2 and W 1 B 1 and so as these parameters change these values a 2 will also change so from the perspective of the third hidden layer these hidden unit values are changing all the time and so is suffering from the problem of covariant shift that we talked about on the previous line so what that Norm does is it reduces the amount that the distribution of these hidden unit values shifts around and if it were to plot the distribution of these hidden unit values maybe this is technically renormalized as V so this is actually V 2 1 and V 2 2 and we're going to values into the full values so we can visualize in 2d what - mom is saying is that the values of V 2 1 and V 2 2 can change and indeed they won't change when the neural network updates the parameters in the earlier layers but what - column ensures is that no matter how it changes the mean and variance of Z 2 1 and V 2 2 will remain the same so so even with the exact values of V 2 1 and V 2 to change their mean and variance while these states say mean 0 and variance 1 or not necessarily mean 0 and variance 1 but whatever value is governed by beta 2 and gamma 2 which is in your networks choosers can force it to be mean 0 and variance 1 or really any other news experience but what this does is it limits the amount to which updating the parameters in the earlier layers can affect the distribution of values that the 3rd layer now sees therefore that has to learn on and so bashed on reduces the problem of the input values changing it really causes these values to become more stable so that the later layers of the neural network has more firm ground to stand on and even though the input distribution changes a bit it changes less and what this does is even as the earlier layers keep learning the amount that this forces the later layers to adapt to the earliest layers changes is reduced or if you will it weakens the coupling between what the earlier layers parameters have to do and what the later layers parameters have to do and so it allows each layer of the network to learn by itself you know a little bit more independently of other layers and this is the effect of speeding up learning in the whole network so I hope this gives some better intuition but the takeaway is that - norm means that especially from the perspective of one of the later layers of the neural network the earlier layers don't get to shift around as much because they're constrained to have the same mean and variance and so this makes the job of learning the later layers easier in terms of batch table has a second effect as a slight regularization impact so one known into the thing about passional is that each mini batch will say mini batch xt has the values VT has the values VL scaled by the meaning variance computed on just that one mini batch now because the mean and variance computed on just that mini batch as opposed to computed on the entire dataset that mean and variance has a little bit of noise in it because this computer just on your mini batch of say 64 or 128 or maybe 256 or larger training examples so because the mean and variance has will be noisy because it's estimated with just a relatively small sample data the scaling process going from VL to z to their L that process is broken noisy as well because it's computed using a slightly noisy mean Darian's so similar to drop out and add some noise to in there's activations the way drop out as noises it takes a hidden unit and it multiplies it by zero with some probability and multiplies it by one with some probability and so dropout has multiplicative noise because it's multiplying by 0 1 whereas - norm has multiple if noise because of scaling by the standard deviation as well as hazardous noise because it's subtracting the mean we're here the estimates of the mean and the standard deviation on noisy and so similar to drop out bashed on therefore has a slight regularization effect because by adding noise to the hidden unit is forcing the downstream pending units not to rely too much on any one hidden unit and so similar to drop out this as noise of hidden layers and therefore has a very slight regularization effect because the noise added is quite small this is not a huge regularization effect and you might choose to use national together with dropouts and you might use bash norm together with dropouts if you want the more powerful regularization effective dropout and maybe one other slightly non-intuitive effect is that if you use a bigger mini-batch size right so if you use a mini batch size of say 512 instead of 64 by using a larger new batch size you're reducing this noise and therefore also reducing this regularization effect so that's one strange property of dropout which is that by using a bigger mini batch size you reduce the regularization effect having said this I wouldn't really use bash norm as a regularizer that's really not the intent of vaginal but sometimes it has this extra intended or unintended effect on your learning algorithm but really don't turn to bash norm as a regularization use it as a way to normalize your hidden units and additions in there for speed of learning and I think the regularization is an almost zero unintended side effect so I hope that gives you better intuition about what batch norm is doing before we wrap up the discussion on batch alarm there's one more detail I want to make sure you know which is that batch norm handles data one mini batch at a time it computes mean and variances on mini batches so at test time we're trying to make predictions johnny valued in your network you might not have a mini batch of examples you might be processing one single example at a time so at test time you need to do something slightly differently to make sure your predictions make sense let in the next and final video on vegetable let's talk over the details of what you need to do in order to taste you in your network train using national to make predictions

Original Description

Take the Deep Learning Specialization: http://bit.ly/2x614g3 Check out all our courses: https://www.deeplearning.ai Subscribe to The Batch, our weekly newsletter: https://www.deeplearning.ai/thebatch Follow us: Twitter: https://twitter.com/deeplearningai_ Facebook: https://www.facebook.com/deeplearningHQ/ Linkedin: https://www.linkedin.com/company/deeplearningai
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from DeepLearningAI · DeepLearningAI · 25 of 60

1 Forward and Backward Propagation (C1W4L06)
Forward and Backward Propagation (C1W4L06)
DeepLearningAI
2 deeplearning.ai's Heroes of Deep Learning: Yuanqing Lin
deeplearning.ai's Heroes of Deep Learning: Yuanqing Lin
DeepLearningAI
3 deeplearning.ai's Heroes of Deep Learning: Ruslan Salakhutdinov
deeplearning.ai's Heroes of Deep Learning: Ruslan Salakhutdinov
DeepLearningAI
4 deeplearning.ai's Heroes of Deep Learning: Yoshua Bengio
deeplearning.ai's Heroes of Deep Learning: Yoshua Bengio
DeepLearningAI
5 deeplearning.ai's Heroes of Deep Learning: Pieter Abbeel
deeplearning.ai's Heroes of Deep Learning: Pieter Abbeel
DeepLearningAI
6 deeplearning.ai's Heroes of Deep Learning: Ian Goodfellow
deeplearning.ai's Heroes of Deep Learning: Ian Goodfellow
DeepLearningAI
7 deeplearning.ai's Heroes of Deep Learning: Andrej Karpathy
deeplearning.ai's Heroes of Deep Learning: Andrej Karpathy
DeepLearningAI
8 Using an Appropriate Scale (C2W3L02)
Using an Appropriate Scale (C2W3L02)
DeepLearningAI
9 Gradient Checking (C2W1L13)
Gradient Checking (C2W1L13)
DeepLearningAI
10 Gradient Checking Implementation Notes (C2W1L14)
Gradient Checking Implementation Notes (C2W1L14)
DeepLearningAI
11 Learning Rate Decay (C2W2L09)
Learning Rate Decay (C2W2L09)
DeepLearningAI
12 Understanding Mini-Batch Gradient Dexcent (C2W2L02)
Understanding Mini-Batch Gradient Dexcent (C2W2L02)
DeepLearningAI
13 Mini Batch Gradient Descent (C2W2L01)
Mini Batch Gradient Descent (C2W2L01)
DeepLearningAI
14 The Problem of Local Optima (C2W3L10)
The Problem of Local Optima (C2W3L10)
DeepLearningAI
15 Exponentially Weighted Averages (C2W2L03)
Exponentially Weighted Averages (C2W2L03)
DeepLearningAI
16 Tuning Process (C2W3L01)
Tuning Process (C2W3L01)
DeepLearningAI
17 Understanding Exponentially Weighted Averages (C2W2L04)
Understanding Exponentially Weighted Averages (C2W2L04)
DeepLearningAI
18 Bias Correction of Exponentially Weighted Averages (C2W2L05)
Bias Correction of Exponentially Weighted Averages (C2W2L05)
DeepLearningAI
19 Gradient Descent With Momentum (C2W2L06)
Gradient Descent With Momentum (C2W2L06)
DeepLearningAI
20 Normalizing Activations in a Network (C2W3L04)
Normalizing Activations in a Network (C2W3L04)
DeepLearningAI
21 Hyperparameter Tuning in Practice (C2W3L03)
Hyperparameter Tuning in Practice (C2W3L03)
DeepLearningAI
22 Adam Optimization Algorithm (C2W2L08)
Adam Optimization Algorithm (C2W2L08)
DeepLearningAI
23 RMSProp (C2W2L07)
RMSProp (C2W2L07)
DeepLearningAI
24 Fitting Batch Norm Into Neural Networks (C2W3L05)
Fitting Batch Norm Into Neural Networks (C2W3L05)
DeepLearningAI
Why Does Batch Norm Work? (C2W3L06)
Why Does Batch Norm Work? (C2W3L06)
DeepLearningAI
26 Batch Norm At Test Time (C2W3L07)
Batch Norm At Test Time (C2W3L07)
DeepLearningAI
27 Softmax Regression (C2W3L08)
Softmax Regression (C2W3L08)
DeepLearningAI
28 Deep Learning Frameworks (C2W3L10)
Deep Learning Frameworks (C2W3L10)
DeepLearningAI
29 Neural Network Overview (C1W3L01)
Neural Network Overview (C1W3L01)
DeepLearningAI
30 Training Softmax Classifier (C2W3L09)
Training Softmax Classifier (C2W3L09)
DeepLearningAI
31 Why Deep Representations? (C1W4L04)
Why Deep Representations? (C1W4L04)
DeepLearningAI
32 Gradient Descent For Neural Networks (C1W3L09)
Gradient Descent For Neural Networks (C1W3L09)
DeepLearningAI
33 Neural Network Representations (C1W3L02)
Neural Network Representations (C1W3L02)
DeepLearningAI
34 TensorFlow (C2W3L11)
TensorFlow (C2W3L11)
DeepLearningAI
35 Activation Functions (C1W3L06)
Activation Functions (C1W3L06)
DeepLearningAI
36 Explanation For Vectorized Implementation (C1W3L05)
Explanation For Vectorized Implementation (C1W3L05)
DeepLearningAI
37 Getting Matrix Dimensions Right (C1W4L03)
Getting Matrix Dimensions Right (C1W4L03)
DeepLearningAI
38 Understanding Dropout (C2W1L07)
Understanding Dropout (C2W1L07)
DeepLearningAI
39 Building Blocks of a Deep Neural Network (C1W4L05)
Building Blocks of a Deep Neural Network (C1W4L05)
DeepLearningAI
40 Why Non-linear Activation Functions (C1W3L07)
Why Non-linear Activation Functions (C1W3L07)
DeepLearningAI
41 Computing Neural Network Output (C1W3L03)
Computing Neural Network Output (C1W3L03)
DeepLearningAI
42 Backpropagation Intuition (C1W3L10)
Backpropagation Intuition (C1W3L10)
DeepLearningAI
43 Train/Dev/Test Sets (C2W1L01)
Train/Dev/Test Sets (C2W1L01)
DeepLearningAI
44 Deep L-Layer Neural Network (C1W4L01)
Deep L-Layer Neural Network (C1W4L01)
DeepLearningAI
45 Random Initialization (C1W3L11)
Random Initialization (C1W3L11)
DeepLearningAI
46 Other Regularization Methods (C2W1L08)
Other Regularization Methods (C2W1L08)
DeepLearningAI
47 Normalizing Inputs (C2W1L09)
Normalizing Inputs (C2W1L09)
DeepLearningAI
48 Derivatives Of Activation Functions (C1W3L08)
Derivatives Of Activation Functions (C1W3L08)
DeepLearningAI
49 Parameters vs Hyperparameters (C1W4L07)
Parameters vs Hyperparameters (C1W4L07)
DeepLearningAI
50 Vectorizing Across Multiple Examples (C1W3L04)
Vectorizing Across Multiple Examples (C1W3L04)
DeepLearningAI
51 What does this have to do with the brain? (C1W4L08)
What does this have to do with the brain? (C1W4L08)
DeepLearningAI
52 Dropout Regularization (C2W1L06)
Dropout Regularization (C2W1L06)
DeepLearningAI
53 Vanishing/Exploding Gradients (C2W1L10)
Vanishing/Exploding Gradients (C2W1L10)
DeepLearningAI
54 Basic Recipe for Machine Learning (C2W1L03)
Basic Recipe for Machine Learning (C2W1L03)
DeepLearningAI
55 Bias/Variance (C2W1L02)
Bias/Variance (C2W1L02)
DeepLearningAI
56 Forward Propagation in a Deep Network (C1W4L02)
Forward Propagation in a Deep Network (C1W4L02)
DeepLearningAI
57 Weight Initialization in a Deep Network (C2W1L11)
Weight Initialization in a Deep Network (C2W1L11)
DeepLearningAI
58 Numerical Approximations of Gradients (C2W1L12)
Numerical Approximations of Gradients (C2W1L12)
DeepLearningAI
59 Regularization (C2W1L04)
Regularization (C2W1L04)
DeepLearningAI
60 Why Regularization Reduces Overfitting (C2W1L05)
Why Regularization Reduces Overfitting (C2W1L05)
DeepLearningAI

This video explains the concept of batch normalization, its benefits, and how it works in deep learning models, providing a fundamental understanding of this crucial technique in neural networks. By watching this video, learners can gain a deeper understanding of how batch normalization improves model performance and stability. The video is part of the Deep Learning Specialization course by DeepLearningAI, which covers the basics of deep learning and its applications.

Key Takeaways
  1. Understand the concept of batch normalization
  2. Learn how batch normalization works in deep learning models
  3. Apply batch normalization to improve model performance
  4. Experiment with different normalization techniques
  5. Evaluate the benefits of batch normalization in deep learning models
💡 Batch normalization is a technique that normalizes the inputs to each layer of a neural network, which can improve the stability and performance of the model.

Related Reads

📰
In-Context Inpainting for Time Series Forecasting
Learn to apply in-context inpainting for time series forecasting using large vision models, transforming time series into visual representations for improved forecasting accuracy
ArXiv cs.AI
📰
Catching bugs in scikit-learn [D]
Learn to catch bugs in scikit-learn by analyzing changes in BayesianRidge uncertainty computation between versions 1.8 and 1.9
Reddit r/MachineLearning
📰
Measure Every Token: A SQLite-Backed Call Tracker for Free Model Endpoints
Build a SQLite-backed call tracker to measure token usage for free model endpoints and gain insights into latency and performance
Dev.to · Dakota Huang
📰
The Bug Was One Axis - And It Only Fires When the Fast Kernels Are Not Installed
Learn how a single reduction over the wrong axis caused a bug in two hybrid models, leaking future information across chunk boundaries, and how to identify similar issues in your own models
Dev.to AI
Up next
Quant Interview Question #quant
quantprof
Watch →