WEBVTT

00:00.080 --> 00:01.080
Welcome back.

00:01.120 --> 00:03.720
We learned about fit function.

00:03.760 --> 00:10.320
We passed the four parameters features, targets, epochs, and verbose.

00:10.640 --> 00:14.680
Now we need to get the trained weights and bias.

00:14.800 --> 00:25.280
At first we need to run all in order to train well this model and wait for the cell to be executed.

00:25.320 --> 00:26.200
And here we go.

00:26.320 --> 00:28.840
The cell is executed correctly.

00:28.880 --> 00:36.920
Now there is a very important thing we need to do which is evaluating the trained weights and bias.

00:36.920 --> 00:47.480
So let's see if the, uh, that the trained weights and bias are close to the equation that we put with

00:47.520 --> 00:50.400
the corresponding data frames.

00:50.400 --> 00:59.800
If we remember that price equals to 2.9 times size plus 2.17, this is from the previous example with

00:59.800 --> 01:05.360
uh, and by the way, this example, the TensorFlow example uses the same data.

01:05.360 --> 01:08.430
So we have the slope is 2.9.

01:08.470 --> 01:12.550
The bias is and the intercept is 2.7.

01:12.870 --> 01:13.390
Okay.

01:13.550 --> 01:20.750
Now let's test those and display the result of bias and the weight from here.

01:20.790 --> 01:28.910
Remember we have the equation y equal to w x plus b y is w and bias is b.

01:28.910 --> 01:34.070
So let me create two variables to be displayed weights and bias.

01:34.190 --> 01:38.590
And thanks for the autogenerated code by the Colab.

01:38.670 --> 01:39.390
Bias.

01:39.550 --> 01:45.630
Weights and bias are two variables assigned by the model layers.

01:45.790 --> 01:47.390
Dot get weights.

01:47.390 --> 01:57.310
Here we are displaying the trained equation and learned weights and bias model dot layers zero index

01:57.350 --> 02:02.030
accesses the first and only layer of our model.

02:02.030 --> 02:07.190
Since our model contains only one layer, we need to access only this first layer.

02:07.350 --> 02:08.710
Get weights.

02:08.750 --> 02:13.390
Returns the learned parameters as the list.

02:13.390 --> 02:15.230
So we have a list here.

02:15.710 --> 02:17.350
Weights of and bias.

02:17.390 --> 02:25.190
We need to access them and display them again guys, in order to get the learned weights and bias,

02:25.230 --> 02:27.870
we use model dot layers.

02:27.870 --> 02:36.190
We are accessing the first layer and only one layer we have here in this simple simple trained model

02:36.350 --> 02:38.390
and get weights.

02:38.390 --> 02:41.470
Function returns the learned parameters as a list.

02:41.470 --> 02:47.670
Weights and bias w equal or y equal w times x plus b.

02:47.750 --> 02:53.470
This is the general formula for linear regression and linear relationships w the weights.

02:53.470 --> 02:57.870
The slope parameter, which is a 2D array shape.

02:57.870 --> 03:06.910
So for that, in order to access it and print it, we use weights and access zero and then zero.

03:06.950 --> 03:08.630
This is a 2D array.

03:08.670 --> 03:17.980
I am accessing this 2D array and the bias get the intercept parameter which is 1D array shape.

03:17.980 --> 03:23.860
So since the bias is 1D array, we use this and access the first index.

03:23.860 --> 03:29.740
And since the weights is a 2D array, we access it like this for.

03:29.780 --> 03:33.860
Let's run and print those parameters and here we go.

03:34.140 --> 03:40.300
The weight equals to 3.005 which is close to 2.9.

03:40.460 --> 03:46.460
And the bias intercept is 2.04 which is close to 2.7.

03:46.660 --> 03:48.580
So congratulations guys.

03:48.780 --> 03:53.260
We trained the model and we get those parameters.

03:53.300 --> 03:57.500
Now let's use those parameters to make the predictions.

03:57.500 --> 04:01.380
So here let me show you guys make predictions.

04:01.380 --> 04:05.340
Predictions equals to model dot predict.

04:05.620 --> 04:08.740
And here pass the x value.

04:08.860 --> 04:13.700
Compare with the original relationship three times size plus two.

04:13.980 --> 04:17.580
Here I am printing the prediction.

04:17.860 --> 04:26.180
The learned relationship price equals to weight times size plus, let me see the original relationship.

04:26.220 --> 04:29.380
Equal price equals to three times size plus two.

04:29.420 --> 04:32.700
This is the, uh, the original relationship.

04:32.940 --> 04:46.460
The learned relationship after we provide the data is 3.0015 times size and plus two, which is 2.0467.

04:46.460 --> 04:46.940
Okay.

04:46.980 --> 04:48.740
So congratulations guys.

04:48.940 --> 04:56.060
We trained our model in a very close manner to get the original relationship, which is three times

04:56.100 --> 04:57.180
size plus two.

04:57.340 --> 05:05.500
In the previous example, we get a close to three which is 2.9 and 2.7.

05:05.660 --> 05:10.540
Also this uh TensorFlow model is well trained.

05:10.740 --> 05:14.620
And congratulations we get this amazing result.

05:14.780 --> 05:21.620
And we get this prediction with original close to the original relationship.
