Contents
How do you use TensorFlow model for prediction?
Summary
- Load EMNIST digits from the Extra Keras Datasets module.
- Prepare the data.
- Define and train a Convolutional Neural Network for classification.
- Save the model.
- Load the model.
- Generate new predictions with the loaded model and validate that they are correct.
How do you deploy a TensorFlow model in production?
For Windows 10, we will use a TensorFlow serving image.
- Step 1: Install the Docker App.
- Step 2: Pull the TensorFlow Serving Image. docker pull tensorflow/serving.
- Step 3: Create and Train the Model.
- Step 4: Save the Model.
- Step 5: Serving the model using Tensorflow Serving.
- Step 6: Make a REST request the model to predict.
How to deploy a model using TensorFlow serving?
The other way is to deploy a model using TensorFlow serving. Since it also provides API (in form of REST and gRPC), so it is portable and can be used in different devices by using its API. It is easy to deploy and works well even for larger models. Part of TensorFlow Extended (TFX) ecosystem.
How to create a TensorFlow model using fastapi?
Whenever we are building an API using FastAPI, we use pydantic to set the type of input our API expects. For eg, a list, dictionary, JSON, string, integer, float. To create an object using pydantic, we use BaseModel that defines our type of inputs.
How is the textvectorization layer used in TensorFlow?
We use Tensorflow’s TextVectorization layer which tidies things up and outputs a layer which we will be using in the process of creating a graph on a Sequential or Functional Model.
Why do we need to use Docker for TensorFlow?
Docker gives us the ability to containerize a solution with all its binding software and requirements. We have used a text classification problem: IMDb Dataset for the purpose of building the model.