Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn TensorFlow Enterprise

You're reading from   Learn TensorFlow Enterprise Build, manage, and scale machine learning workloads seamlessly using Google's TensorFlow Enterprise

Arrow left icon
Product type Paperback
Published in Nov 2020
Publisher Packt
ISBN-13 9781800209145
Length 314 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
KC Tung KC Tung
Author Profile Icon KC Tung
KC Tung
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Section 1 – TensorFlow Enterprise Services and Features
2. Chapter 1: Overview of TensorFlow Enterprise FREE CHAPTER 3. Chapter 2: Running TensorFlow Enterprise in Google AI Platform 4. Section 2 – Data Preprocessing and Modeling
5. Chapter 3: Data Preparation and Manipulation Techniques 6. Chapter 4: Reusable Models and Scalable Data Pipelines 7. Section 3 – Scaling and Tuning ML Works
8. Chapter 5: Training at Scale 9. Chapter 6: Hyperparameter Tuning 10. Section 4 – Model Optimization and Deployment
11. Chapter 7: Model Optimization 12. Chapter 8: Best Practices for Model Training and Performance 13. Chapter 9: Serving a TensorFlow Model 14. Other Books You May Enjoy

Converting a full model to a reduced float16 model

In this section, we are going to load the model we just trained and quantize it into a reduced float16 model. For the convenience of step-by-step explanations and your learning experience, it is recommended that you use JupyterLab or Jupyter Notebook to follow along with the explanation here:

  1. Let's start by loading the trained model:
    import tensorflow as tf
    import pathlib
    import os
    import numpy as np
    from matplotlib.pyplot import imshow
    import matplotlib.pyplot as plt
    root_dir = '../train_base_model'
    model_dir = ' trained_resnet_vector-unquantized/save_model'
    saved_model_dir = os.path.join(root_dir, model_dir)
    trained_model = tf.saved_model.load(saved_model_dir)

    The tf.saved_model.load API helps us to load the saved model we built and trained.

  2. Then we will create a converter object to refer to the savedModel directory with the following line of code:
    converter = tf.lite.TFLiteConverter.from_saved_model...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime