6

I'm trying to load a model trained with keras by running:

model = load_model('model.h5')

but I get the following:

File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/keras/models.py", line 258, in load_model
custom_objects=custom_objects)
File "/usr/local/lib/python3.5/dist-packages/keras/optimizers.py", line 689, in deserialize
printable_module_name='optimizer')
File "/usr/local/lib/python3.5/dist-packages/keras/utils/generic_utils.py", line 142, in deserialize_keras_object
return cls.from_config(config['config'])
File "/usr/local/lib/python3.5/dist-packages/keras/optimizers.py", line 127, in from_config
return cls(**config)
File "/usr/local/lib/python3.5/dist-packages/keras/optimizers.py", line 403, in __init__
super(Adam, self).__init__(**kwargs)
File "/usr/local/lib/python3.5/dist-packages/keras/optimizers.py", line 63, in __init__
'passed to optimizer: ' + str(k))
TypeError: Unexpected keyword argument passed to optimizer: amsgrad

I'm using Keras 2.1.2 and tensorflow 1.4.1

2 Answers 2

12

AMSgrad has been added on 11.12.2017 to Keras https://github.com/keras-team/keras/pull/8693 whereas Keras 2.1.2 has been built on 01.12.2017 https://github.com/keras-team/keras/releases/tag/2.1.2

So either you need to wait on the next release or install Keras from scratch if the model uses it.

3
9

Keras version 2.1.3 is required so you could just go with

pip install keras==2.1.3
2
  • What about tf.keras.models.load_model
    – devssh
    Jan 31, 2019 at 10:45
  • Ah it got fixed when I restarted my jupyter notebook kernel
    – devssh
    Jan 31, 2019 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.