let's say I've got 2500 time series of class A, and 2500 time series of class B, both 1000 time steps long. There is only one numerical feature per time series. I want to train a LSTM using Keras to classify the time series into one of the two classes. They can be easily distinguished using features which require the LSTM to understand the time correlation between the data, like one class has a seasonal pattern, while the other hasn't. Therefore I want to use a stateful LSTM.

But I'm totally confused about how to construct the input_dimensions for Keras.

As far as I understand it the input for the LSTM is defined as (samples, time steps, features).

Is my X now (5000,1000,1) and I call model.fit() exactly once? When do I call model.reset_states()?

Or do I show the time series each time step at a time, so my input is (1,1,1) and I just show it then 5000 times for each time series 1000 times per each time step the single feature, so call model.fit() 5,000,000 times?! I would then call after I'm finished with one time series the model.reset_states() method to forget everything for the new time series, right?

Or is it (1,1000,1), and I call model.reset_states() after calling fit() 5000 times (per time series)?


closed as off-topic by mkt, kjetil b halvorsen, Michael Chernick, mdewey, Sycorax Jan 29 at 15:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – mkt, kjetil b halvorsen, Michael Chernick, mdewey, Sycorax
If this question can be reworded to fit the rules in the help center, please edit the question.