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
[TF 2.0 keras] Unable save and load weights for double nested models #27769
Comments
This only affected .h5 format, tensorflow checkpoints format works fine. |
@zzh8829 What is the alternative way to save a model/weights? I am having this proble min .hdf5 fromat too. |
@abhigyank the alternative is save to |
Any news on this issue? I tried the *.tf and it works. |
It might seem like .tf saving works but in my experience the only difference is that it doesn't throw an error. |
I am currently submitting a fix for H5. @veqtor What problem are you seeing with using the TF format? |
Changed the test to the example from #27769. PiperOrigin-RevId: 254305891
@k-w-w I have tested your fix and it works for me 😃 Thank you a lot! |
@k-w-w How can I use your fix? I have the same problem. |
@19giorgosts The fix should be in tensorflow-nightly, which you can install using |
I am new coder to keras。 Can you show me a demo about your description? |
@Lannist Here is the colab gist to save/load the weights in *.tf format. Here is the gist to save/load the weights in *.h5 format. The only difference between those two gist is in changing the extension. Thanks! I am closing the issue as it was resolved in |
is this change gonna be in tf 1 ? |
have you found the solution? |
how about tensorflow 1.1.4 or 1.1.5 |
That didn't work for me, using that fix in tf-nightly, for a siamese model such as:
|
System information
Describe the current behavior
load_weights throw exception on a doubly nested model
Describe the expected behavior
load_weights should work
This problem only happens on two+ layers of nested model with non-trainable weights.
The reason is save_weights and load_weights handles nested model differently
save_weights -> call layer.weights for each layer
load_weights -> recursively call model.weights if layer is a nested Model
Code to reproduce the issue
Other info / logs
This bug is also reported on upstream keras keras-team/keras#11847
Here is a detailed analysis on why this is happening keras-team/keras#11847 (comment)
Full Exception
The text was updated successfully, but these errors were encountered: