TypeError: Unexpected keyword argument passed to optimizer: learning_rate

Did you use a custom optimizer?

If so, you can load like this:

model = load_model('my_model_name.h5', custom_objects={
    'Adam': lambda **kwargs: hvd.DistributedOptimizer(keras.optimizers.Adam(**kwargs))
})

Alternatively you can load your model with model = load_model('my_model_name.h5', compile=False) and then add an optimizer and recompile, but that will lose your saved weights.


This happened to me too. Most likely because the learning_rate was renamed from version 2.2.* to 2.3.0 in September 2018. (see release notes: https://github.com/keras-team/keras/releases : Rename lr to learning_rate for all optimizers. )

This worked for me:

sudo pip install keras --upgrade