TypeError: Unexpected keyword argument passed to optimizer: learning_rate

Chayan Bansal picture Chayan Bansal · Sep 20, 2019 · Viewed 25.9k times · Source

I am trying to load a Keras model which was trained on an Azure VM (NC promo). But I am getting the following error.

TypeError: Unexpected keyword argument passed to optimizer:learning_rate

EDIT:

Here is the code snippet that I am using to load my model:

from keras.models import load_model
model = load_model('my_model_name.h5')

Answer

MichaelF picture MichaelF · Oct 25, 2019

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