Code launched in Google Colab:
Hello,
I tried to launch a code example provided in the Keras documentation, concerning a CNN using the CIFAR-10 dataset. Here is the link: CIFAR-10 CNN.
Unfortunately, even with the latest stable versions of Tensorflow and Keras, executing the code leads to an error:
TypeError: Unexpected keyword argument passed to optimize: learning_rate
The error therefore comes from the following line of code:
opt = keras.optimizers.RMSprop(learning_rate=0.0001, decay=1e-6)
However, if I look at the _optimizers_ documentation, "learning_rate" is an argument which is supposed to be accepted by the "RMSprop" class. Le
class RMSprop(Optimizer):
"""RMSProp optimizer.
It is recommended to leave the parameters of this optimizer
at their default values
(except the learning rate, which can be freely tuned).
# Arguments
learning_rate: float >= 0. Learning rate.
rho: float >= 0.
...
"""
def __init__(self, learning_rate=0.001, rho=0.9, **kwargs):
self.initial_decay = kwargs.pop('decay', 0.0)
self.epsilon = kwargs.pop('epsilon', K.epsilon())
learning_rate = kwargs.pop('lr', learning_rate)
...
Regards
TBX
Try lr and not learning_rate. Then it should work.
Something funny is going on here as the source file is using lr correctly but the web version Optimizers doc is falsely using learning_rate.
update to keras 2.3.1 , then it will be fine. 2.2.5 seems not to have included 'learning_rate' keyword arg. This Problem especially happens when code was written in 2.3.1 and one tries to load model from lower version.
Most helpful comment
update to keras 2.3.1 , then it will be fine. 2.2.5 seems not to have included 'learning_rate' keyword arg. This Problem especially happens when code was written in 2.3.1 and one tries to load model from lower version.