Inside TensorFlow: Quantization aware training
Vložit
- čas přidán 29. 06. 2024
- In this episode of Inside TensorFlow, Software Engineer Pulkit Bhuwalka presents quantization aware training. Pulkit will take us through the fundamentals of quantization aware training, TensorFlow/Keras API used to achieve this, and how it is implemented during this tutorial.
Documentation → goo.gle/32MN60q
Github → goo.gle/30YihDB
Add the Inside TensorFlow playlist → goo.gle/Inside-TensorFlow
Subscribe to the TensorFlow channel → goo.gle/TensorFlow - Věda a technologie
Hey all, at 14:26, are we missing the quantize_annotate_layer wrapper over the Conv2d layer (inside Sequential), like this:
quantize_annotate_layer(tf.keras.layers.Conv2d(32, 5, input_shape=(28,28,1))
GitHub link doesn't work. Audio is terrible.
Hey can you re-upload with better audio, please?
Sorry about that. I recorded the audio locally so it's better, but forgot Airpods audio compression over bluetooth lost quality.
@@alias15vapour All good, it happens. The topic seems really interesting tho, so I'd really appreciate it if you could re-upload or re-record it sometime. Thanks!
@@athreyamurali1439 - Thanks. This takes a bunch of post-production work, so a bit unlikely tbh but me (or someone else on the team) will definitely do this and a better job for the next version.
Get better microphone
I can't hear anything
same
i am having a problem when i convert my .h5 to tflite,, when i test the tflite on my mobile app the accuracy is so much lower than when i try to run the .h5 on jupyter.... my question is does quantization aware training can help me to lower the accuracy loss when converted it to tflite after the quantization aware training?
please someone help!!!
When I try to post-quantize(int8) the SimpleRNN model for a time series data, it is throwing an error saying only single graph is supported. So Does the RNN, LSTMs support for quantization and conversion to tflite models? And If yes, how can I address the error? Thanks in advance.:)
Hey Pulkit,
Say I wanted to constrain quantization parameters to power of 2 values. Would that be supported?
I'm using QAT for a functional model only, but I'm getting a value error saying,
quantize_model
'`to_quantize` can only either be a tf.keras Sequential or '
ValueError: `to_quantize` can only either be a tf.keras Sequential or Functional model.
I'm not really sure why I'm getting this error. Could anyone please help me out in this?
I tried QAT, as result I got .h5 model with quantize wrapper layers, I want to remove it and get back my original model with modified weights, How can I dot that?
Very good Sir
I have trained ssd_mobilenet_v2 model using object detection api and saved the model as .pb file. How to apply the quantization to a my model. I dont have .h5 file.
for object detection, QAT Works, if so how?
I got this error whatever I do (the same if the network only contains Dense layers...) : ValueError: Unable to clone model. This generally happens if you used custom Keras layers or objects in your model. Please specify them via `quantize_scope` for your calls to `quantize_model` and `quantize_apply`. [Layer supplied to wrapper is not a supported layer type. Please ensure wrapped layer is a valid Keras layer.].
Have you found the solutions?
Is there any scenarios in which quantisation shouldn't be done? Like, Incase I want to convert it to other formats supporting optimization, such as TensorRT.
That depends on your needs. If you want to use TensorRT for optimization that works fine as well. Quantization is useful if performance is a concern for you.
Thanks for sharing! Does it support mixed precision?
it should, he mentioned custom quantization for specific layers
QAT does emulation of model execution in certain precisions so model accuracy is preserved. If that's your goal, you can totally do it like Bryan mentioned. But it's unlike mixed precision for training.
Documentation → goo.gle/2WMUZze ---> ERROR (Sorry, we couldn't find that page.)
Can this be used for tensor cores on Nvidia GPUs or is it only for embedded devices?
By default it supports the TFLite Quantization spec. If you want to use it for Nvidia, you would have to write custom quantization configs specific to NVidia. But it absolutely can be done.
@@alias15vapour Thanks for the answer, would that be writing CUDA kernels for this or could you wrap with something higher level like Tensorrt?
@@yoloswaggins2161 You wouldn't need to write any kernels. You would just need to arrange the TF graph in a way that it emulates the quantization on Nvidia chips. It would just reuse their existing kernels.
Possible to use TensorRT but you would need to know deep internals of TensorRT to construct the graph correctly.
@@alias15vapour I see, thank you.
Waiting for a video for sequential modelling
Hey how should I start start learning Deep learning ? Could you suggest me?
@@rushikeshgandhmalhow’s your learning journey🎉
The Github link in the description doesn't work
Sorry about that, there's a typo. Just use the link below.
Bruh, is someone weed-whacking outside?
Unfortunately, yes. They started that the moment I started recording :(