automl icon indicating copy to clipboard operation
automl copied to clipboard

How to apply quantization aware training on keras model?

Open drahmad89 opened this issue 5 years ago • 2 comments

The typical approach consists of taking a keras model and pass it to tfmot.quantization.keras.quantize_model() This approach does not work in case of efficientdet keras model. I got a value error : ValueError: to_quantize can only either be a tf.keras Sequential or Functional model. cause the model class is neither Sequential no Functional typical keras model. It seems more like class aggregating different part and each part is a class inherited from tf.keras.model. I am not an expert in Keras and would appreciate any hint to guide me for running a qat with efficientdet.

drahmad89 avatar Sep 09 '21 13:09 drahmad89

in tf2/train.py

I added the following code lines in setup_model function

quantize_model = tfmopt.quantization.keras.quantize_model #qaware stands for for quantization aware. model.build((None, *config.image_size, 3)) print(type(model)) model_quant = quantize_model(model)

drahmad89 avatar Sep 09 '21 13:09 drahmad89

@drahmad89 Any luck on getting answers to your questions in this issue? Can we quantize or prune Efficientdet models?

judahkshitij avatar Mar 17 '22 19:03 judahkshitij