Error module ‘keras.optimizers’ has no attribute ‘RMSprop’

We Are Going To Discuss About Error module ‘keras.optimizers’ has no attribute ‘RMSprop’. So lets Start this Python Article.

Error module ‘keras.optimizers’ has no attribute ‘RMSprop’

  1. How to solve Error module 'keras.optimizers' has no attribute 'RMSprop'

    As you said, you installed tensorflow (which includes keras) via pip install tensorflow, and not keras directly. Installing keras via pip install keras is not recommended anymore (see also the instructions here).
    This means that keras is available through tensorflow.keras. Instead of importing via from keras import optimizers, you should use from tensorflow.keras import optimizers.

  2. Error module 'keras.optimizers' has no attribute 'RMSprop'

    As you said, you installed tensorflow (which includes keras) via pip install tensorflow, and not keras directly. Installing keras via pip install keras is not recommended anymore (see also the instructions here).
    This means that keras is available through tensorflow.keras. Instead of importing via from keras import optimizers, you should use from tensorflow.keras import optimizers.

Solution 1

As you said, you installed tensorflow (which includes keras) via pip install tensorflow, and not keras directly. Installing keras via pip install keras is not recommended anymore (see also the instructions here).

This means that keras is available through tensorflow.keras. Instead of importing via from keras import optimizers, you should use from tensorflow.keras import optimizers.

Original Author Daniel Lenz Of This Content

Solution 2

You should instead write:

from tensorflow import keras
from keras import optimizers
optimizer=keras.optimizers.RMSprop(learning_rate=0.01)

Original Author user17911402 Of This Content

Solution 3

It works

from keras.optimizers import rmsprop_v2
model.compile(loss='binary_crossentropy', optimizer='rmsprop')

but I don’t know why..

Original Author henrylee henrylee Of This Content

Solution 4

I faced the same error, and I avoid it by importing optimizers
like that :

from tensorflowf.keras import optimizers

then I applied the RMSprop :

optimisers.RMSprop(...)

Original Author bart-khalid Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment