AttributeError: 'function' object has no attribute 'history'

Here are my codes to obtain the graph:

from keras.callbacks import History , ModelCheckpoint
model_LSTM.compile(loss='mae', optimizer = 'adam')

history_LSTM =, y_train, epochs=20, batch_size=64, validation_data=(X_val, y_val), verbose=0, shuffle=False)

plt.plot(history.history['loss'], "b+-", label='training', color = "red")
plt.plot(history.history['val_loss'], "b+-", label='validation', color = "blue")
plt.title('Feed Forward')
plt.xlabel('Training Epochs', fontsize=16)
plt.ylabel('Mean Absolute error', fontsize=16)
plt.xlim(0, 20)

when I run it, it gives this error:

AttributeError: 'function' object has no attribute 'history'

This isn’t a Jupyter issue. You’d have the same issue if you ran this in pure Python as a script.

You probably want to consult examples of the use of history, for example here. Shouldn’t it be in your case?

plt.plot(history_LSTM.history['loss'], "b+-", label='training', color = "red")

And so forth …

If you adapt code from the example, you have to carry forward the references to what you changed.
And investigate how to debug your Python code. There’s a lot on this topic out there.

And in the future you’ll want to make sure you have the correct forum for your questions. Often examining other recent posts will let you know if you are in the correct place.

I tried all the suggestions I found like this suggestion that you gave.
Sorry I’m new in the forum, that’s why my question was not in the correct place.
Thank you.