Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'keras.optimizers' has no attribute 'rmsprop'

Tags:

python

I got an error of AttributeError: module 'keras.optimizers' has no attribute 'rmsprop' for the below code. I am using tensorflow 2 with python 3.8.

# training
batch_size = 64
epochs=125

from keras import regularizers, optimizers
from keras.callbacks import ModelCheckpoint   

checkpointer = ModelCheckpoint(filepath='model.125epochs.hdf5', verbose=1, save_best_only=True)

optimizer = keras.optimizers.rmsprop(lr=0.0003,decay=1e-6)
model.compile(loss='categorical_crossentropy', optimizer=optimizer, metrics=['accuracy'])
history = model.fit_generator(datagen.flow(x_train, y_train, batch_size=batch_size), callbacks=[checkpointer],
                steps_per_epoch=x_train.shape[0] // batch_size, epochs=epochs,verbose=2,
                validation_data=(x_test,y_test))

AttributeError: module 'keras.optimizers' has no attribute 'rmsprop'

enter image description here

like image 486
roudan Avatar asked Oct 11 '25 16:10

roudan


1 Answers

Because rms should be in capitals.

optimizer = keras.optimizers.RMSprop(lr=0.0003, decay=1e-6)
like image 92
Luisa Sanchez Avatar answered Oct 14 '25 07:10

Luisa Sanchez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!