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 argumen
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
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.
Similar to Chayan Bansal, what fixed it for me was to update my Tensorflow-GPU library.
If you're using Anaconda with tensorflow-gpu installed, open the Anaconda prompt, activate the virtual environment you're using, and enter "conda update tensorflow-gpu"
I was running into the same thing. You will have to upgrade to Tensorlfow 2.0 and Keras, or match the two systems together.
I had the same problem. Using Keras version 2.3.1 and TensorFlow-GPU version 1.13, I had to upgrade Tensorflow-GPU to version 1.15
pip uninstall tensorflow-gpu
pip install tensorflow-gpu==1.15
I've had a similar problem.
You you have this issue, try to use lr
instead of learning_rate
when defining the learning rate in your optimizer.