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’
- 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 viapip install keras
is not recommended anymore (see also the instructions here).
This means that keras is available throughtensorflow.keras
. Instead of importing viafrom keras import optimizers
, you should usefrom tensorflow.keras import optimizers
. - 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 viapip install keras
is not recommended anymore (see also the instructions here).
This means that keras is available throughtensorflow.keras
. Instead of importing viafrom keras import optimizers
, you should usefrom 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.