#25 Machine Learning Specialization [Course 1, Week 2, Lesson 2]
Key Takeaways
This video covers the technique of feature scaling to improve the performance of gradient descent in machine learning, using a concrete example of predicting house prices with two features: size and number of bedrooms.
Full Transcript
so welcome back let's take a look at some techniques that make gradient descents work much better in this video you see a technique called feature scaling that will enable gradient descent to run much faster let's start by taking a look at the relationship between the size of a feature that is how big are the numbers for that feature and the size of its Associated parameter as a concrete example let's predict the price of a house using two features X1 the size of the hulls and X2 the number of bedrooms let's say that X1 typically ranges from 300 to 2000 square feet and x2 in the data set ranges from 0 to 5 bedrooms so for this example X1 takes on a relatively large range of values and X2 takes on a relatively small range of values now let's take an example of a house that has a size of 2 000 square feet has five bedrooms and a price of 500k or 500 000 dollars for this one trading example what do you think are reasonable values for the size of parameters W1 and W2 well let's look at one possible set of parameters say W1 is 50 and W2 is 0.1 and B is 50 for the purposes of discussion so in this case the estimated price in thousands of dollars is 100 000 K here plus 0.5 K plus 50k which is slightly over a hundred million dollars so that's clearly very far from the actual price of five hundred thousand dollars and so this is not a very good set of parameter choices for W1 and W2 now let's take a look at another possibility say W1 and W2 were the other way around W1 is 0.1 and W2 is 50 and B is still also 50. in this choice of W1 and W2 W1 is relatively small and W2 is relatively large 50 is much bigger than 0.1 so here the predicted price is 0.1 times 2 000 plus 50 times 5 plus 50. the first term becomes 200k the second term becomes 250k and then plus 50. so this version of the model predicts a price of five hundred thousand dollars which is a much more reasonable estimate and happens to be the same price as the true price of the house so hopefully you might notice that when a possible range of values of a feature is large like the size in square feet which goes all the way up to 2000 it's more likely that a good model will learn to choose a relatively small parameter value like 0.1 likewise when the possible values of a feature are small like the number of bedrooms then a reasonable value for its parameters will be relatively large like 50. so how does this relate to gradient descent well let's take a look at a scatter plot of the features where the size is square feet is the horizontal axis X1 and the number of bedrooms X2 is on the vertical axis if you plot the training data you notice that the horizontal axis is on a much larger scale or much larger range of values compared to the vertical axis next let's look at how the cost function might look in a contour plot you might see a contour plot where the horizontal axis has a much narrower range say between 0 and 1 whereas the vertical axis takes on much larger values say between 10 and 100. so the Contours form ovals or ellipses and they are short on one side and longer on the other and this is because a very small change to W1 can have a very large impact on the estimated price and thus a very large impact on the cost J because W1 tends to be multiplied by a very large number the size in square feet in contrast it takes a much larger change in W2 in order to change the predictions much and thus small changes to W2 don't change the cost function nearly as much so where does this leave us this is what might end up happening if you were to run gradient descent if you were to use your training data as is because the Contours are still tall and skinny gradient descents may end up bouncing back and forth for a long time before it can finally find its way to the global minimum in situations like this a useful thing to do is to scale the features this means performing some transformation of your training data so that X1 save might not range from 0 to 1 and X2 might also range from 0 to 1. so today the points now look more like this and you might notice that the scale of the plot on the bottom is now quite different than the one on top the key point is that the rescale X1 and X2 are both now taking comparable ranges of values to each other and if you run gradient descent on a cost function defined on this rescaled X1 and X2 using this transform data then the Contours will look more like this more like circles and less tall and skinny and great in descents can find a much more direct path to the global minimum so to recap when you have different features that take on very different ranges of values it can cause gradient descent to run slowly but rescaling the different features so they all take on comparable range of values can speed upgrade and descent significantly how do you actually do this let's take a look at that in the next video
Original Description
The Machine Learning Specialization is a foundational online program created in collaboration between DeepLearning.AI and Stanford Online. This beginner-friendly program will teach you the fundamentals of machine learning and how to use these techniques to build real-world AI applications.
This Specialization is taught by Andrew Ng, an AI visionary who has led critical research at Stanford University and groundbreaking work at Google Brain, Baidu, and Landing.AI to advance the AI field.
This video is from Course 1 (Supervised Machine Learning Regression and Classification), Week 2 (Regression with multiple input variables), Lesson 2 (Gradient descent in practice), Video 1 (Feature scaling part 1).
To learn more and access the full course videos and assignments, enroll in the Machine Learning Specialization here: https://bit.ly/3ERmTAq
Download the course slides: https://bit.ly/3AVNHwS
Check out all our courses: https://bit.ly/3TTc2KA
Subscribe to The Batch, our weekly newsletter: https://bit.ly/3TZUzju
Follow us:
Facebook: https://www.facebook.com/DeepLearningAIHQ/
LinkedIn: https://www.linkedin.com/company/deeplearningai/
Twitter: https://twitter.com/deeplearningai_
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from DeepLearningAI · DeepLearningAI · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Forward and Backward Propagation (C1W4L06)
DeepLearningAI
deeplearning.ai's Heroes of Deep Learning: Yuanqing Lin
DeepLearningAI
deeplearning.ai's Heroes of Deep Learning: Ruslan Salakhutdinov
DeepLearningAI
deeplearning.ai's Heroes of Deep Learning: Yoshua Bengio
DeepLearningAI
deeplearning.ai's Heroes of Deep Learning: Pieter Abbeel
DeepLearningAI
deeplearning.ai's Heroes of Deep Learning: Ian Goodfellow
DeepLearningAI
deeplearning.ai's Heroes of Deep Learning: Andrej Karpathy
DeepLearningAI
Using an Appropriate Scale (C2W3L02)
DeepLearningAI
Gradient Checking (C2W1L13)
DeepLearningAI
Gradient Checking Implementation Notes (C2W1L14)
DeepLearningAI
Learning Rate Decay (C2W2L09)
DeepLearningAI
Understanding Mini-Batch Gradient Dexcent (C2W2L02)
DeepLearningAI
Mini Batch Gradient Descent (C2W2L01)
DeepLearningAI
The Problem of Local Optima (C2W3L10)
DeepLearningAI
Exponentially Weighted Averages (C2W2L03)
DeepLearningAI
Tuning Process (C2W3L01)
DeepLearningAI
Understanding Exponentially Weighted Averages (C2W2L04)
DeepLearningAI
Bias Correction of Exponentially Weighted Averages (C2W2L05)
DeepLearningAI
Gradient Descent With Momentum (C2W2L06)
DeepLearningAI
Normalizing Activations in a Network (C2W3L04)
DeepLearningAI
Hyperparameter Tuning in Practice (C2W3L03)
DeepLearningAI
Adam Optimization Algorithm (C2W2L08)
DeepLearningAI
RMSProp (C2W2L07)
DeepLearningAI
Fitting Batch Norm Into Neural Networks (C2W3L05)
DeepLearningAI
Why Does Batch Norm Work? (C2W3L06)
DeepLearningAI
Batch Norm At Test Time (C2W3L07)
DeepLearningAI
Softmax Regression (C2W3L08)
DeepLearningAI
Deep Learning Frameworks (C2W3L10)
DeepLearningAI
Neural Network Overview (C1W3L01)
DeepLearningAI
Training Softmax Classifier (C2W3L09)
DeepLearningAI
Why Deep Representations? (C1W4L04)
DeepLearningAI
Gradient Descent For Neural Networks (C1W3L09)
DeepLearningAI
Neural Network Representations (C1W3L02)
DeepLearningAI
TensorFlow (C2W3L11)
DeepLearningAI
Activation Functions (C1W3L06)
DeepLearningAI
Explanation For Vectorized Implementation (C1W3L05)
DeepLearningAI
Getting Matrix Dimensions Right (C1W4L03)
DeepLearningAI
Understanding Dropout (C2W1L07)
DeepLearningAI
Building Blocks of a Deep Neural Network (C1W4L05)
DeepLearningAI
Why Non-linear Activation Functions (C1W3L07)
DeepLearningAI
Computing Neural Network Output (C1W3L03)
DeepLearningAI
Backpropagation Intuition (C1W3L10)
DeepLearningAI
Train/Dev/Test Sets (C2W1L01)
DeepLearningAI
Deep L-Layer Neural Network (C1W4L01)
DeepLearningAI
Random Initialization (C1W3L11)
DeepLearningAI
Other Regularization Methods (C2W1L08)
DeepLearningAI
Normalizing Inputs (C2W1L09)
DeepLearningAI
Derivatives Of Activation Functions (C1W3L08)
DeepLearningAI
Parameters vs Hyperparameters (C1W4L07)
DeepLearningAI
Vectorizing Across Multiple Examples (C1W3L04)
DeepLearningAI
What does this have to do with the brain? (C1W4L08)
DeepLearningAI
Dropout Regularization (C2W1L06)
DeepLearningAI
Vanishing/Exploding Gradients (C2W1L10)
DeepLearningAI
Basic Recipe for Machine Learning (C2W1L03)
DeepLearningAI
Bias/Variance (C2W1L02)
DeepLearningAI
Forward Propagation in a Deep Network (C1W4L02)
DeepLearningAI
Weight Initialization in a Deep Network (C2W1L11)
DeepLearningAI
Numerical Approximations of Gradients (C2W1L12)
DeepLearningAI
Regularization (C2W1L04)
DeepLearningAI
Why Regularization Reduces Overfitting (C2W1L05)
DeepLearningAI
More on: ML Maths Basics
View skill →Related Reads
📰
📰
📰
📰
Mixture of Experts Is Not an Efficiency Trick — It’s a Systems Philosophy
Medium · Machine Learning
Explainable Causal Reinforcement Learning for autonomous urban air mobility routing under real-time policy constraints
Dev.to AI
5 ARB and ICU edge cases I wish I'd tested earlier
Dev.to · Evgenii Sokolov
RQLM Part 3: The Instruction Pointer Was Already There
Medium · Machine Learning
🎓
Tutor Explanation
DeepCamp AI