Welcome back.
We saved and exported the trained model successfully.
Now let's learn how to load saved models.
Your exported model consists of.
Saved model file.
Model architecture.
Graph.
Graph variables.
Folder.
Model.
Weights and training state.
Assets folder.
Additional files like vocabularies and the fingerprint of PB file.
You typically can't just load the single PB file.
I can't load this saved model PB file alone because it only contains the model architecture, not the
weights.
The PB file needs the variables folder to work properly.
To do the correct loading process of the exported models, we need to use our friend TensorFlow.
So here loading the exported Models.
Let's start by creating a new variable called loaded model equals to TensorFlow dot saved model dot
load.
And here you should specify the exact name of the linear regression export model or any other model
you need to load.
So here please pay attention to the name of the model.
It should match this or otherwise it will give you an error.
Print TensorFlow model loaded successfully.
Let's run.
And here we go TensorFlow model loaded successfully.
Now we're going to work with this loaded model.
We're going to forget the model that we created locally.
And we're now we're going to use this loaded model.
So let's test the loaded model.
Let me make some predictions here.
We need to access the default serving function.
Serve function equals to loaded modal.
I'm accessing this loading loaded modal signatures and serving defaults.
Here we get the main function that do the job.
Then we're going to use the loaded model to make predictions.
So test input variable equals to t f dot constant.
Let me pass $1,500.
So this is the size sorry 1500ft² of the size of the uh, of the house.
And we need to get the prediction of the price.
Okay.
Then run the inference serve function, the function that we we need to access and the default serving
function.
And we pass the test input, which is $1,500.
So here sorry square feet size equals to Square feet.
Okay, let me print the predictions.
Run here.
And here we go.
Prediction output tensor flow shape one one array, one dimension.
And the float of the output is uh is of type float and num array.
We can we have an array here containing the result which is 6.5 for thousand dollars.
So the prediction works fine.
Here we are getting the type of the prediction which is a float, and a num array which is a 6.54,
which is the result of 1500ft² house.
Okay.
So congratulations guys.
We loaded successfully the model and we use it in order to make.