9

I am trying to replicate the code on http://machinelearningmastery.com/time-series-prediction-lstm-recurrent-neural-networks-python-keras/ (first example). The code can be found in the part "LSTM Networks for Regression". However, my question mainly refers to the following line:

model.fit(trainX, trainY, epochs=100, batch_size=1, verbose=2)

When I execute this line, I get the following Exception:

model.fit(trainX, trainY, batch_size=1, verbose=2, epochs = 100) File "/usr/local/lib/python2.7/site-packages/keras/models.py", line 612, in fit str(kwargs)) Exception: Received unknown keyword arguments: {'epochs': 100}

If I leave the keyword 'epochs' away, everything works fine. But of course, this is highly unsatisfactory since I want to increase the number of epochs. Can anyone help?

Peter Series
  • 289
  • 3
  • 9

1 Answers1

21

The epoch flags were CHANGED in version 2+, for version 1+ use nb_epoch instead.

model.fit(trainX, trainY, nb_epoch=100, batch_size=1, verbose=2)

To check your Keras version ..

import keras
print(keras.__version__)
Butsuri
  • 738
  • 9
  • 14
  • 1
    That solved it. By the way: If you want to update to the newest Keras version so to use 'epochs' instead of 'nb_epoch', you can use the pip command `pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps` – Peter Series Apr 21 '17 at 22:19
  • I'm glad that I found this, because the [keras documentation](https://keras.io/models/model/#fit) needs to be updated to reflect this change as well. – Ryan May 23 '17 at 17:53