Welcome back.
We learned about fit function.
We passed the four parameters features, targets, epochs, and verbose.
Now we need to get the trained weights and bias.
At first we need to run all in order to train well this model and wait for the cell to be executed.
And here we go.
The cell is executed correctly.
Now there is a very important thing we need to do which is evaluating the trained weights and bias.
So let's see if the, uh, that the trained weights and bias are close to the equation that we put with
the corresponding data frames.
If we remember that price equals to 2.9 times size plus 2.17, this is from the previous example with
uh, and by the way, this example, the TensorFlow example uses the same data.
So we have the slope is 2.9.
The bias is and the intercept is 2.7.
Okay.
Now let's test those and display the result of bias and the weight from here.
Remember we have the equation y equal to w x plus b y is w and bias is b.
So let me create two variables to be displayed weights and bias.
And thanks for the autogenerated code by the Colab.
Bias.
Weights and bias are two variables assigned by the model layers.
Dot get weights.
Here we are displaying the trained equation and learned weights and bias model dot layers zero index
accesses the first and only layer of our model.
Since our model contains only one layer, we need to access only this first layer.
Get weights.
Returns the learned parameters as the list.
So we have a list here.
Weights of and bias.
We need to access them and display them again guys, in order to get the learned weights and bias,
we use model dot layers.
We are accessing the first layer and only one layer we have here in this simple simple trained model
and get weights.
Function returns the learned parameters as a list.
Weights and bias w equal or y equal w times x plus b.
This is the general formula for linear regression and linear relationships w the weights.
The slope parameter, which is a 2D array shape.
So for that, in order to access it and print it, we use weights and access zero and then zero.
This is a 2D array.
I am accessing this 2D array and the bias get the intercept parameter which is 1D array shape.
So since the bias is 1D array, we use this and access the first index.
And since the weights is a 2D array, we access it like this for.
Let's run and print those parameters and here we go.
The weight equals to 3.005 which is close to 2.9.
And the bias intercept is 2.04 which is close to 2.7.
So congratulations guys.
We trained the model and we get those parameters.
Now let's use those parameters to make the predictions.
So here let me show you guys make predictions.
Predictions equals to model dot predict.
And here pass the x value.
Compare with the original relationship three times size plus two.
Here I am printing the prediction.
The learned relationship price equals to weight times size plus, let me see the original relationship.
Equal price equals to three times size plus two.
This is the, uh, the original relationship.
The learned relationship after we provide the data is 3.0015 times size and plus two, which is 2.0467.
Okay.
So congratulations guys.
We trained our model in a very close manner to get the original relationship, which is three times
size plus two.
In the previous example, we get a close to three which is 2.9 and 2.7.
Also this uh TensorFlow model is well trained.
And congratulations we get this amazing result.
And we get this prediction with original close to the original relationship.