'ValueError: Unknown layer: QuantizeLayer

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)


Solution 1:[1]

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)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Elad Cohen