After Updating from tf 2.7 to any higher tensorflow version (i have tested them all), the loading of my previously trained models does not work anymore. When I downgrade Tensorflow the imports work again as expected. I get this as an error:
TypeError: No common supertype of TensorSpec(shape=(None, None, 80), dtype=tf.float32, name=None) and TensorSpec(shape=(None, None, 80), dtype=tf.float16, name='x').
I think this similar error explains the problem but I cannot change anything in the source code of TF since I need to distribute my model. Is there a way to get around this error because it would be very limiting to be stuck with TF 2.7!
The Problem appeared after saving the model with mode.save() and then reloading it with tf.keras.models.load_model().
I was working on that now for over a month (on/off) and just after posting the question found the solution:
Use tf.saved_model.load(model_weights_path)
instead of tf.keras.models.load_model(model_weights_path, compile=False)
. I leave the question here maybe someone can explain me why this works after TF 2.7 and the other one not?