Skip to content

Latest commit

 

History

History
 
 

tf_example7

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

tf_example7 example

This example is used to demonstrate how to quantize a TensorFlow model with dummy dataset.

Step-by-Step

Prerequisite

1. Installation

pip install -r requirements.txt

Note: Validated TensorFlow Version.

2. Download the FP32 model

wget https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_6/mobilenet_v1_1.0_224_frozen.pb

Run

1. Run Command

python test.py

2. Introduction

We can quantize a model only needing to set the dataloader with dummy dataset to generate an int8 model.

    # Built-in dummy dataset
    dataset = Datasets('tensorflow')['dummy'](shape=(1, 224, 224, 3))
    # Built-in calibration dataloader and evaluation dataloader for Quantization.
    dataloader = DataLoader(framework='tensorflow', dataset=dataset)
    # Post Training Quantization Config
    config = PostTrainingQuantConfig()
    # Just call fit to do quantization.
    q_model = fit(model="./mobilenet_v1_1.0_224_frozen.pb",
                  conf=config,
                  calib_dataloader=dataloader)