Open ypsilon-elle opened 2 years ago
Hey @jvishnuvardhan, did you have time to look at this issue? We really would appreciate some feedback on this.
This is very similar to this issue. Please take a look. Thanks!
This is very similar to this issue. Conv2Dtranspose is not supported in quantization. Please take a look. Thanks!
@gowthamkpr Thanks for the link, I have checked the issue. The issue might be outdated, because it is from 2020.
To my knowledge Conv2Dtranspose
is supported by quantization aware training. A quantization config for Conv2Dtranspose
is defined in /default_8bit/default_8bit_quantize_registry.py. In fact, a Conv2Dtranspose
layer can be quantized successfully, such a model can be trained with QAT and saved as h5. Please see the attached colabs in the issue description.
However saving a model with q-aware Conv2Dtranspose
as .pb fails. So, by the look of it, something goes wrong in model.save()
.
Saving the same model as .h5 works (unfortunately this workaround is not suitable for us because our technical requirement is to save a .pb-model).
Is it because you want to export the model for inference?
As a workaround you may want to try to use tf.saved_model.save(model, name)
and see if that works.
@fchollet I have a technical requirement to save my model in .pb format because this is a format which is used in other parts/modules of the project where I have to pass my model to. Saving my model as .h5 is a temporary workaround and I am hoping for a permanent solution :)
Thanks for you suggestion. Unfortunately the same error is reproducible with tf.keras.models.save_model()
too.
Also adding @abattery from TFMOT team.
Hi, any news on this?
Originally I posted this bug #54753 on tensorflow/tensorflow and was advised to repost it here.
System information
Describe the problem We save a quantization-aware keras-model in a .pb model format using
model.save()
. This operation fails withValueError: __inference_conv2d_transpose_layer_call_fn_4530
when our model contains aConv2DTranspose
layer.tf.keras.models.save_model()
tootfmot.quantization.keras.quantize_model()
tf.keras.models.clone_model()
and apply quantization usingtfmot.quantization.keras.quantize_apply()
. Our current workaround is to not annotateConv2DTranspose
but this prevents us from having a fully quantization-aware model.Saving the same model as .h5 works (unfortunately this workaround is not suitable for us because our technical requirement is to save a .pb-model).
Describe the expected behavior
model.save()
saves a QAT model with aConv2DTranspose
layer in a .pb-format successfully.Standalone code to reproduce the issue Here are the collabs to reproduce the issue using a very simple model with a
Conv2DTranspose
layer and two ways to make a model quantization aware mentioned above:Other info / logs Similar issue #868