-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
keras-3: saving weights in legacy h5 format fails for custom layer containing two sub-layers of the same type. #19375
Comments
Hi, As the warning suggests,
If you change the code |
Do you say by this that the old keras2 saving format is unsupported in keras3? |
It is supported, but it is suggested to use .keras format since it works seamlessly. |
OK, we could live with that, loading old models saved in legacy format and saving them in the new format. |
Saving in older version and loading it in Keras 3 may not work as expected, it is highly recommended to save the model in .keras and load it back in the same format, since it has all the model config details. |
Thanks for the report. I have fixed the issue with the legacy h5 format at HEAD. |
Reference commit: 2c30d86 |
Keras-3 assigns short names to weights, which is handy, but when it saves weights in legacy h5 format it picks names as:
weight_names = [w.name.encode("utf8") for w in weights]
instead of:
weight_names = [w.value.name.encode("utf8") for w in weights] # old naming
The file is: /keras/src/legacy/saving/legacy_h5_format.py
function: save_subset_weights_to_hdf5_group()
See the stack trace and a sample for the failure reproduction.
stack.log
reproduction.py.txt
The text was updated successfully, but these errors were encountered: