-
Notifications
You must be signed in to change notification settings - Fork 118
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
Ensure backwards compatibility for legacy H5 saving format #682
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
model.add(layers.TimeDistributed(layers.Dense(3))) | ||
model.compile(optimizer="rmsprop", loss="mse") | ||
|
||
tf_keras_model = tf.keras.Sequential() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future tf.keras
will be Keras Core. So can we avoid depending on it, and instead depend on a static artifact? Maybe either downloaded or checked into git?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, however, for now as I develop and expand this testing suite I will keep this dependency for debugging purposes/changes. After the full testing suite is done (in the next PR or so), I will generate them as h5 artifacts and add them to that PR.
@@ -484,6 +484,12 @@ def deserialize(config, custom_objects=None): | |||
arg_spec = inspect.getfullargspec(cls.from_config) | |||
custom_objects = custom_objects or {} | |||
|
|||
# TODO(nkovela): Replace during Keras 3.0 release | |||
# Replace keras refs with keras_core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the swap, the replacement should go the other way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, fixed the TODO comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR ensures backwards compatibility for the legacy H5 saving format, particularly paying attention to differences in configs, arguments, and deserialization methods between tf.keras and Keras Core.
A few tests have been added showing a tf.keras model saved into H5 and then loaded into Keras Core to become a Keras Core model.
The test suite will be expanded in subsequent PRs to ensure greater coverage.