I’m currently developing some model optimization using TensorFlow by trying different features (quantization, weight pruning…) in some of my company models.
My problem comes when I convert an h5 model to .tflite without any type of special optimization with the following code:
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
with open('model.tflite', 'wb') as f:
f.write(tflite_model)
The model (MobileNet v2) size went from 18.5 MB to 8.9 MB and accuracy from 99.48% to 98.51%
I can’t explain this change that is also happening in other models, for example, this ResNet50:
94.9MB to 94MB and 98.51% to 94.51%.
Why is the conversion to .tflite reducing weight and accuracy without any type of extra optimization?