I'm running keras on a remoter server with SSH, training LSTM, the training process works correctly, the model is like this:
model = Sequential()
model.add(Masking(mask_value=0., input_shape=(None, len(chars))))
model.add(LSTM(4000, return_sequences=True))
model.add(LSTM(4000, return_sequences=True))
model.add(TimeDistributed(Dense(len(chars))))
model.add(Activation('softmax'))
rmsprop=RMSprop(lr=0.006)
model.compile(loss='categorical_crossentropy', optimizer=rmsprop)
after I training, I saved the model:
json_string = model.to_json()
open('my_model_architecture21.json', 'w').write(json_string)
model.save_weights('my_model_weights21.h5',overwrite=True)
but this part works abnormally, as when I reload weights after training, the model works like never been trained, the same script works correctly in my one laptop. this is really strange, anyone have an idea? thanks very much!
Facing the same issue #4875
But for me it is working fine if it is in same session. Even model.save() doesn't seem to be working in this matter.
The problem has been solved with changing the version of pythonand keras, previously I'm using python3andkeras 1.2.0, after reinstall python2 and keras 1.1.0, it works correctly.
why you don not use these lines of code:
1- save the model:
model.save(path+'\name.hdf5')
2- load the model:
from keras.models import load_model
model=load_model(path+'\name.hdf5')
On Wed, Jan 4, 2017 at 9:28 AM, MrWanter notifications@github.com wrote:
The problem has been solved with changing the version of pythonand keras,
previously I'm using python3andkeras 1.2.0, after reinstall python2 and keras
1.1.0, it works correctly.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/fchollet/keras/issues/4904#issuecomment-270309729,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARxwS9qb7DSbaaFtFoXqAok9GfizJC5qks5rO0okgaJpZM4LZcik
.
--
Hany A. EL-Ghaish
E-JUST University
*PhD Candidate at School of Communication and Computer Engineering,
Egypt-Japan University of Science and Technology *
M. 01004393715
@MrWanter do you mean this is the problem of newer version of keras on python 3?
Yes, I think maybe there is a problem with that, you can try to use different version.
@fchollet is this a known issue? If yes is there any workaround to avoid this in python 3?
Edit: I'm not able to save and load a model with python 2 and keras 1.1 also
Interesting. Did some of you verify that loaded weights are the same as before saving?
@alexander-rakhlin yes both weights are same. But the thing is the issue is not always reproducible. Currently I'm using jupyter notebook in Azure VM with python 2.7 and Keras from github. It seems to work fine. But the same setup is not working in heroku jupyter notebook, with same setup. And I'm not able to pinpoint the root cause.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.
I'm also facing this issue, accuracy changes every time I load weights.
If you are working with RL, check your initialization of epsilon of the epsilon greedy....it should be equal to 0 other than 1 when evaluating...really stupid mistake, but it just happened...
Most helpful comment
Facing the same issue #4875
But for me it is working fine if it is in same session. Even model.save() doesn't seem to be working in this matter.