IDAES/idaes-pse

Resolve Keras File Format Issues

bpaul4 opened this issue · 6 comments

TensorFlow updated to version 2.16.1 on March 8, 2024. Python 3.9+ tests that install the latest package now throw errors similar to the message below:

E           ValueError: File format not supported: filepath=D:\a\idaes-pse\idaes-pse\idaes\core\surrogate\plotting\tests\keras_surrogate. Keras 3 only supports V3 `.keras` files and legacy H5 format files (`.h5` extension). Note that the legacy SavedModel format is not supported by `load_model()` in Keras 3. In order to reload a TensorFlow SavedModel as an inference-only layer in Keras 3, use `keras.layers.TFSMLayer(D:\a\idaes-pse\idaes-pse\idaes\core\surrogate\plotting\tests\keras_surrogate, call_endpoint='serving_default')` (note that your `call_endpoint` might have a different name).

Tests and code that use Keras should be updated accordingly.

@rundxdi I briefly investigated the issue and it will require updating the KerasSurrogate "save_to_folder" and "load_from_folder" methods with serialization to a ".keras" format instead, and related front-end changes in tests that use the methods. Please work on this when you can, as it is a breaking issue in IDAES at the moment. Thank you.

@rundxdi I briefly investigated the issue and it will require updating the KerasSurrogate "save_to_folder" and "load_from_folder" methods with serialization to a ".keras" format instead, and related front-end changes in tests that use the methods. Please work on this when you can, as it is a breaking issue in IDAES at the moment. Thank you.

Thanks for identifying the needed updates. I'll take a look tomorrow and work on updates this week.

@rundxdi any estimate on this?

@rundxdi any news on this? Maybe join the next dev call to update us?

@rundxdi any news on this? Maybe join the next dev call to update us?

@ksbeattie I should finally have an update at or before the next dev call, sorry for the delay!

@ksbeattie I've opened PR #1401 to address this. It should fix keras_surrogate.py and test_keras_surrogate.py. However, I'm having trouble getting test_keras_plotting.py to work with the changes and its existing model. Working on that currently.