Keras: RMSprop optimizer - Argument not recognized

Created on 26 Sep 2019  路  3Comments  路  Source: keras-team/keras


Code launched in Google Colab:

  • Keras version : 2.2.5
  • Tensorflow version : 1.14.0

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

tensorflow

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.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings