New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tf keras upsample2d operator produces wrong results on tflite conversion #45090
Comments
|
I met the same problem, additonal shape, mul and strided slice layer(not supported by hardware accelerators). |
|
@Saduf2019 when I set my batch dim with 1 these layers was disappear; |
|
@sunzhe09 How did you set batch dim to 1 ? The tfllite already has batch size 1 right? |
|
@Saduf2019 If we set the batch dimesion to input layer during model defintion of tf.keras model, all the problems seems to be resolved. However can we set the batch dimension of all layers for the already trained model to 1, before tflite conversion? |
|
This is similar to issue #43882. See my explanation on why this is correct and an example on how to set your model shape to be static before conversion |
|
For anyone wondering. For single input keras model the fix above can be implemented like this. |

System information
Command used to run the converter or code if you’re using the Python API
If possible, please share a link to Colab/Jupyter/any notebook.
Colab Link: https://colab.research.google.com/drive/1QZo8QZubmiiXIxc0O8SZEfEsfaxN5kxR?usp=sharing
Failure details
The conversion is successful, but the generated model is wrong,
The tf keras model with upsample2d layers(bilinear interpolation) correctly produces a h5 file; but the converted tflite model has extra layers and there is shape mismatch.The output shape becomes 1x1 instead of original upsampled size. The error occurs in tf 2.3.0, tf nightly and latesr source (dev 2.5.0). The conversion produces additonal shape, mul and strided slice layer(not supported by hardware accelerators).
The problem persists even if we use ResizeNearestNeighbor interpolation.
Minimal Example
Models
mnv3_resize_bilinear_test.zip
The text was updated successfully, but these errors were encountered: