ValueError: Unknown layer: QuantizeLayer

1.5k Views Asked by At

After QAT training with tensorflow_model_optimization followed the tutorial

then use Keras to load the quantized model will show Unknown layer: QuantizeLayer

   tf.keras.models.load_model(keras_quantized_model_file)
1

There are 1 best solutions below

0
RyanLiu On

The problem solved by the following code:

import tensorflow_model_optimization as tfmot

with tfmot.quantization.keras.quantize_scope():
    loaded_model = tf.keras.models.load_model(keras_quantized_model_file)