yashmaniya0 / Quantization-of-Image-Classification-Models

Comprehensive study on the quantization of various CNN models, employing techniques such as Post-Training Quantization and Quantization Aware Training (QAT).
2 stars 0 forks source link

Question about annotation for quantization #1

Closed oumaymabelhajsalah96 closed 3 days ago

oumaymabelhajsalah96 commented 5 days ago

Hello, thank you for sharing the source code of your work. I would like to understand this error related to annotation, which occurred across all the different models :

ValueError Traceback (most recent call last)

in () 9 return layer 10 ---> 11 annotated_model = tf.keras.models.clone_model( 12 model, 13 clone_function=apply_quantization_to_dense, 5 frames /usr/local/lib/python3.10/dist-packages/tensorflow_model_optimization/python/core/quantization/keras/quantize.py in quantize_annotate_layer(to_annotate, quantize_config) 268 if not isinstance(to_annotate, keras.layers.Layer) or isinstance( 269 to_annotate, keras.Model): --> 270 raise ValueError( 271 '`to_annotate` can only be a `keras.layers.Layer` instance. ' 272 'You passed an instance of type: {input}.'.format( ValueError: `to_annotate` can only be a `keras.layers.Layer` instance. You passed an instance of type: Dense.
yashmaniya0 commented 4 days ago

Make sure that you haven't changed the following function :

def apply_quantization_to_dense(layer):
  if isinstance(layer, tf.keras.layers.Dense):
    return tfmot.quantization.keras.quantize_annotate_layer(layer)
  return layer

Also check the versions of following imports. It is working fine with tensorflow==2.7.0 and tensorflow_model_optimization==0.7.4

oumaymabelhajsalah96 commented 3 days ago

Thank you for your response. Please, what version of Python is compatible with these two libraries? I tried to install these two libraries with Python 3.7.0 locally on my machine, but I encountered an incompatibility issue between numpy and tensorflow-model-optimization. And is there any free online platform where I can work on them?

Le jeu. 21 nov. 2024, 13:23, Yash Maniya @.***> a écrit :

Make sure that you haven't changed the following function :

def apply_quantization_to_dense(layer): if isinstance(layer, tf.keras.layers.Dense): return tfmot.quantization.keras.quantize_annotate_layer(layer) return layer

Also check the versions of following imports. It is working fine with tensorflow==2.7.0 and tensorflow_model_optimization==0.7.4

— Reply to this email directly, view it on GitHub https://github.com/yashmaniya0/Quantization-of-Image-Classification-Models/issues/1#issuecomment-2490996687, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUVFOBVHOMFVYWJZY2AORBD2BXGCXAVCNFSM6AAAAABSGP3HSKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJQHE4TMNRYG4 . You are receiving this because you authored the thread.Message ID: <yashmaniya0/Quantization-of-Image-Classification-Models/issues/1/2490996687 @github.com>

yashmaniya0 commented 3 days ago

I was working with Python 3.9.13 and you can use google Colab if you want to.

oumaymabelhajsalah96 commented 23 hours ago

Thank you.

Le sam. 23 nov. 2024, 11:35, Yash Maniya @.***> a écrit :

I was working with Python 3.9.13 and you can use google Colab if you want to.

— Reply to this email directly, view it on GitHub https://github.com/yashmaniya0/Quantization-of-Image-Classification-Models/issues/1#issuecomment-2495432795, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUVFOBU32TEDDLFQ5JTHCMT2CBK6VAVCNFSM6AAAAABSGP3HSKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJVGQZTENZZGU . You are receiving this because you authored the thread.Message ID: <yashmaniya0/Quantization-of-Image-Classification-Models/issues/1/2495432795 @github.com>