我想量化一个 DenseNet 模型。我正在使用 TensorFlow 2.4。
import tensorflow_model_optimization as tfmot
model = tf.keras.applications.DenseNet121(include_top=True,weights=None,input_tensor=None,input_shape=None,pooling=None,classes=1000)
quantize_model = tfmot.quantization.keras.quantize_model
model = quantize_model(model)
但我收到以下消息:
RuntimeError:层 conv2_block1_0_bn:<class 'tensorflow.python.keras.layers.normalization_v2.BatchNormalization'> 不受支持。您可以通过将tfmot.quantization.keras.QuantizeConfig
实例传递给quantize_annotate_layer
API 来量化这一层。
有没有办法我可以做到这一点。我无法更改 keras 代码。