-
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
load_model fails to load optimizer #3964
Comments
I have kind of the same problem reported here: #3974
|
I installed HDFview and opened the hdf5 file and deleted the optimizer part of the file. Now I can load the model and it works like a charm ! However, I think it is a bug and should get fixed. |
This worked for me. Thanks |
I solved the problem by using load_weights function is keras.model. My solution is at issue #4044 . Maybe it's useful for you. |
I am afraid, this issue is not solved, and should be re-opened, as it still occurs in the latest Keras version. |
I solved the issue by making sure that the exact version and subversion of the environment that creates and loads the model are the same. Ex. Im creating and training the model with keras 2.0.3, the VM that loads it has to run keras 2.0.3 as well, 2.0.0 won't work. |
I solved the issue by upgrading from 2.0.2 to 2.0.3. Perhaps there should be a way to maintain interoperability? @kiennguyen94 |
Do you have a specific example of a script that:
|
I've trained a model with the following code: https://gist.github.com/apacha/f52935d1225ccbb21d66fd5f4011d387 Note two things: I've omitted the code for actually loading the data (see this repository for the entire code). And it works with other models like this one. Interestingly this code works: otherwise I get this error:
I'm using Keras 2.0.3 and Tensorflow-Gpu 1.0.1 |
+1 The issue is still not solved. |
Same here |
@sakvaua did you save the model in Keras 2.0.2? I had saved the model in Keras 2.0.3 and tried to load it in 2.0.2. When I upgraded and tried loading it in 2.0.3 it worked. It seems a fix could be to modify |
@zafarali. Hmmm. I have 2.0.4 and models are saved and loaded during the same session. |
Still have same issue with 2.0.4 It seems to be related to creating new optimizers or reusing layers in different models. |
I solved the issue by compelling congruency between the versions of Keras installed on my different machines. It makes sense to think working with the same model across different versions of the library could engender hiccups due to discrepancies in convention employed in said versions. First I looked up what versions were installed on my different machines (Guide here: https://stackoverflow.com/a/10215100/2661720), and for the machine on which I was loading the model, I overwrote the existing Keras version with that installed on the model's parent machine (Guide here: https://stackoverflow.com/a/33812968/2661720). This was the thought process that sublimated the problem for me. |
Seems to me that this error comes up when I try to load too many models at the same time. Currently I'm loading a number of different models into a test script to be tested one at a time. Is there a way to force tensorflow to forget a graph? Bet that would solve it for people in my situation. |
@tstandley clear_session() |
@sakvaua Thanks. You're awesome! Wish I knew about this sooner. A more informative error message would also help, but I don't know how to distinguish the two scenarios. |
Ensuring the same version of Keras is installed in both settings (2.0.6 in my case) solved the problem. |
Closing since the issue is fixed with the current version. |
Please make sure that the boxes below are checked before you submit your issue. Thank you!
pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps
pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps
Not sure what the specific cause is yet and how to isolate it, but I'm having some issues using the
load_model
method. I get the below error complaining about weight shape for the optimizer.image ordering does not impact this. The model has some 1D convolutions, fully connected layers, merging, and some custom layers. If I instead use
model_from_json
and them callload_weights
then no problem occurs.The text was updated successfully, but these errors were encountered: