AttributeError: 'RMSprop' object has no attribute 'build'

Hi all,

im a beginner and i tried to save and open a trained model.
This model is defined as follows:

from keras.models import Sequential
from keras.layers import LSTM

model = Sequential()
model.add(LSTM(1, input_shape=(20,1)))
model.compile(optimizer=‘rmsprop’, loss=“mse”),Y, batch_size=32, epochs=10)

I can save the model by‘xxxxxx.keras’), but i cannot get it loaded; this leads to an error:

AttributeError: ‘RMSprop’ object has no attribute ‘build’

What did i do wrong? :slight_smile:

Welcome to Tensorflow Forum!

We can try multiple workaround as below:

  1. Replace below line
    model.compile(optimizer=‘rmsprop’, loss=“mse”)
    With this
    model.compile(optimizer='rmsprop', loss='mse')

  2. If the above doesn’t work, try replacing ‘rmsprop’ with ‘tf.keras.optimizers.RMSprop’

  3. I have prepared a gist, refer the below link to debut the issue.
    Google Colab

Let us know if this solve the problem.

1 Like

Hi Tanya,

thank you very much for your advise.
Unfortunatly, it does not work - on both of my macs by the way.

So it seems that this is a local and device based problem :slight_smile:

I found a workaround by saving the model to a json file:

model_json = model.to_json()
with open(“model.json”, “w”) as json_file:

This works well and without problems.