Open kennysong opened 1 year ago
@gowthamkpr, I was able to reproduce the issue on tensorflow v2.8, v2.9, v2.10 and nightly. Kindly find the gist of it here. Model Gist, Gist1 where as on v2.7 the model was able to load. Thank you!
Hi Kenny, this is been fixed in the latest version of tf-nightly and it works. Keras team is coming up with a new format that ends with .keras
extension. This works in both keras format .keras
and saved model .tf
format. Heres the gist. Try running it and it should work. Thanks!!
Hi @gowthamkpr, thanks for the response!
Unfortunately, this does not resolve the issue. tf-nightly
(2.12.0-dev20221114
) is still unable to load the SavedModels from TF 2.7 and 2.6.
The problem is that the SavedModel is incompatible across TF versions. There is no problem loading a SavedModel with the same version of TF used to generate it.
Thanks for filing! Will take a deeper look.
@kennysong, Since the migration, there were many changes made, the error you are getting is due to one such change here https://github.com/keras-team/tf-keras/commit/cff6ac903e2b8a0dde2a469d949f0f0ce3b5f282.
To get rid of the error, you need to install tf-keras-nightly as well as tf-nightly.
Note that, tf-keras-nightly is legacy Keras code, to use the Keras 3 with multi-backend support, use keras-nightly and import Keras directly.
Also I tried to execute the Keras tutorial on tensorflow v2.14 and tried loading on v2.15 and it happened without any issues. Kindly find the gist of it here. Thank you!
This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.
Hi @tilakrayal, I tried loading the tutorial TF 2.7 SavedModel in TF 2.14, 2.15, and tf-nightly + tf-keras-nightly, and none of them worked. (Here's the TF 2.7 SavedModel file which you can replicate from the notebook linked in the first comment.)
In TF 2.14 and 2.15, the error is the same as previously reported.
In TF nightly (Keras 3), SavedModels cannot be directly loaded as noted in the migration guide. This wrapper code seems to work:
m = keras.Sequential(
[keras.layers.TFSMLayer('tutorial_model_tf26', call_endpoint="serving_default")]
)
But I wasn't able to easily get the loaded model to make a prediction due to lack of documentation. Pointers would be appreciated!
This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.
This issue is not stale.
System information.
Describe the problem.
I ran the official Keras tutorial "Structured data classification from scratch" in TF 2.7, and saved the model as a SavedModel.
This SavedModel successfully loads in TF 2.7, but cannot be loaded TF 2.8, 2.9, or 2.10. Error message:
Based my my tests, here's a compatibility table for saving/loading this model across TF versions:
Standalone code to reproduce the issue.
Colab to train and save the Keras tutorial model: https://colab.research.google.com/drive/1c-UDWPW0OQjbgItijs_4UB4sm-dQ7MdS?usp=sharing
Colab to load the Keras tutorial SavedModel: https://colab.research.google.com/drive/1KM9nUBdsqGFW5zXUuU7b2ZtcKA1BiUXz?usp=sharing