WEBVTT

00:00.120 --> 00:01.120
Welcome back.

00:01.160 --> 00:05.760
In our model we have nine features cylinders displacement.

00:05.760 --> 00:06.480
Horsepower.

00:06.480 --> 00:06.880
Weight.

00:06.880 --> 00:07.720
Acceleration.

00:07.720 --> 00:10.240
Model year one, two and three.

00:10.280 --> 00:17.720
Now those are the features that the input layer takes as parameters and as features.

00:17.720 --> 00:26.760
Also in the hierarchy of our model we have hidden layer number one with 64 neurons learning complex

00:26.760 --> 00:27.600
patterns.

00:27.800 --> 00:37.360
Then we have another layer, another 64 neurons called hidden layer number two that learn more patterns.

00:37.360 --> 00:42.800
And then we have the output layer which is the mileage and the mpg.

00:42.920 --> 00:43.480
Okay.

00:43.800 --> 00:46.720
We talked about this hierarchy in the previous videos.

00:46.720 --> 00:48.600
Now let's code.

00:48.640 --> 00:56.080
Let's create a function that creates a reusable model that follows this hierarchy.

00:56.120 --> 01:03.400
We have input layer hidden layer number one, hidden layer number two and the input output layer under

01:03.440 --> 01:05.080
the feature scaling.

01:05.240 --> 01:10.970
Here we need to start building the neural network and build the model architecture.

01:11.170 --> 01:12.370
New code.

01:12.530 --> 01:15.650
Let's start defining a new function.

01:15.850 --> 01:18.330
Def build model.

01:18.450 --> 01:26.170
And to build a model we start with model equals to TensorFlow Keras dot sequential.

01:26.370 --> 01:30.090
And we talked about this in the previous videos.

01:30.250 --> 01:32.770
But don't worry we're going to lecture it.

01:32.810 --> 01:34.530
This is the first layer.

01:34.530 --> 01:36.370
This is the input layer.

01:36.370 --> 01:40.850
So here let me make it as input layer.

01:40.970 --> 01:46.170
We have TF dot dot layers dot dance.

01:46.170 --> 01:48.370
We are creating a dense layer.

01:48.370 --> 01:59.130
So this code means that we are going to create a TensorFlow layer a dense layer 64 neurons first hidden

01:59.130 --> 02:03.890
layer with 64 units and activation ReLU.

02:04.010 --> 02:10.090
ReLU introduces non-linearity returns maximum zero and x.

02:10.090 --> 02:13.570
So here we have nonlinear.

02:13.810 --> 02:19.940
The input shape automatically adapts to the number of feature in scaled data.

02:20.140 --> 02:29.540
We can use train X train keys, but I prefer using the exit train X train scaled.

02:29.580 --> 02:31.980
We we used the scaled.

02:31.980 --> 02:34.900
We're going to use the scaled data.

02:34.900 --> 02:40.620
So here get the shape and pass the parameter one.

02:40.660 --> 02:46.460
So this will automatically adapt to number of feature in scaled data.

02:46.460 --> 02:50.700
So we are using the scaled data not the exit train.

02:50.860 --> 02:52.460
Please pay attention guys.

02:52.740 --> 02:55.060
Don't use X train data.

02:55.100 --> 02:59.140
Use the exit train underscore scaled okay.

02:59.180 --> 03:05.660
Because we uh we introduced the feature scaling in the uh, previous videos.

03:05.660 --> 03:09.860
And we talked about exit train scaled okay.

03:09.900 --> 03:13.820
So our data now becomes X train scaled.

03:13.860 --> 03:20.100
We need to deal and train our model with this trained and scaled data.

03:20.260 --> 03:24.820
The second layer we need to create is the hidden layer.

03:24.900 --> 03:31.900
So hidden layer number one we start with tf dot dot layer dot dense.

03:31.900 --> 03:41.100
In order to create any layer we start with tensorflow.keras dot layers dot dense 64 activation ReLU

03:41.420 --> 03:49.820
and another hidden layer df dot dot layer dot dense.

03:49.900 --> 03:53.980
Here we can use not dense layer.

03:53.980 --> 03:58.380
We can use drop out 0.2.

03:58.420 --> 04:10.420
Why we don't use dense because we need to prevent overfitting and dropout 0.2 randomly drops 20% of

04:10.700 --> 04:14.020
neurons during training to prevent overfitting.

04:14.020 --> 04:19.500
So here we have 20% for the training data, for the testing data.

04:19.740 --> 04:27.300
And here we set the randomly drops 20% of neurons during training to prevent overfitting.

04:27.540 --> 04:35.310
The third and or the fourth and last layer is the output layer.

04:35.310 --> 04:37.110
So output layer.

04:37.310 --> 04:38.510
How to create it.

04:38.550 --> 04:40.390
Start with df dot.

04:41.590 --> 04:42.430
Dot layer.

04:42.470 --> 04:49.750
Dot dense equals to one one neuron for regression and no activation.

04:49.750 --> 04:58.270
So here one neuron okay so we have only one neuron for regression and no activation.

04:58.430 --> 05:01.710
Don't miss to close this sequential.

05:01.710 --> 05:05.350
So this is our um our sequential.

05:05.390 --> 05:07.230
How to create the model layers.

05:07.230 --> 05:11.030
We start by Keras tf.keras dot sequential.

05:11.070 --> 05:15.350
This is the function used for creating the the layers.

05:15.350 --> 05:25.310
We created the input layer with one with 64 neurons activation, ReLU and input shape.

05:25.350 --> 05:28.230
We use the scaled trained x.

05:28.270 --> 05:30.910
Then we create the hidden layer number one.

05:30.950 --> 05:35.310
We create the hidden layer number two and the output layer.
