How to make LSTM predict multiple time steps ahead?

I am trying to use a LSTM for time series prediction. The data streams in once per minute, but I would like to predict an hour ahead. There are two ways I can think of for going about this:

1. Squash the data into hourly data instead, taking the average over each 60 minute time period as one data point.
2. For each (X, y) training data pair, let X be the time series from t - 120 to t - 60, and let y be the time series from t - 60 to t. Force the LSTM to predict 60 timesteps ahead, and take y[-1] as the prediction.

• What is LSTM? Least squares time series model maybe? – Michael Chernick Mar 4 '17 at 19:55
• Do you need 60 predictions, or just the last one? If you just need the last one, just feed in y = t+60 value to train. I don't think it's critical (for LSTM) that the value you are predicting is the very next one sequentially. So if you want predictions further out in time, just train it that way. – photox Mar 5 '17 at 21:36
• use multi-step forecasting with the data per minutes you have with appropriate lag value – SATYAJIT MAITRA May 14 at 1:31

There are different approaches

• Recursive strategy

• one many-to-one model

prediction(t+1) = model(obs(t-1), obs(t-2), ..., obs(t-n))
prediction(t+2) = model(prediction(t+1), obs(t-1), ..., obs(t-n))

• Direct strategy

• multiple many-to-one models

prediction(t+1) = model1(obs(t-1), obs(t-2), ..., obs(t-n))
prediction(t+2) = model2(obs(t-2), obs(t-3), ..., obs(t-n))

• Multiple output strategy

• one many-to-many model

prediction(t+1), prediction(t+2) = model(obs(t-1), obs(t-2), ..., obs(t-n))

• Hybrid Strategies

• combine two or more above strategies

Reference : Multi-Step Time Series Forecasting

train = [[t-120,t-199...t,t+1...t+60],[...],[...]]

# fit an LSTM network to training data
def fit_lstm(train, n_lag, n_seq, n_batch, nb_epoch, n_neurons):
# reshape training into [samples, timesteps, features]
X, y = train[:, 0:n_lag], train[:, n_lag:]
X = X.reshape(X.shape, 1, X.shape)
# design network
model = Sequential()
model.add(LSTM(n_neurons, batch_input_shape=(n_batch, X.shape, X.shape), stateful=True))