I want to do 1D-CNN and quantization aware training, it gives error keras.src.layers.convolutional.conv1d.Conv1D'> is not supported.You can quantize this layer by passing a `tfmot.quantization.keras.QuantizeConfig` instance to the `quantize_annotate_layer` API.. I search lots of information, it still not work.
The Code
model = tf.keras.models.Sequential([
tf.keras.layers.Conv1D(4, 16, strides= 1,padding='same', activation= 'relu'),
tf.keras.layers.MaxPooling1D(pool_size=3, strides=2, padding='same'),
...
])
def apply_quantization(layer):
if isinstance(layer, (tf.keras.layers.Conv1D, tf.keras.layers.Flatten, tf.keras.layers.Dense)):
return tfmot.quantization.keras.quantize_annotate_layer(layer)
return layer
annotated_model = tf.keras.models.clone_model(
model,
clone_function=apply_quantization,
)
qat_model = tfmot.quantization.keras.quantize_apply(annotated_model)
qat_model.summary()
I fixed the bug. Delete the code below the
def, and then add: