简体   繁体   中英

Multiple Parallel Input and Multi-Step Output time series forecasting

I am learning time series forecasting using LSTM model. I found a nice tutorial https://machinelearningmastery.com/how-to-develop-lstm-models-for-time-series-forecasting/ I am trying Stacked LSTM for the problem in "Multiple Parallel Input and Multi-Step Output" part.

The dataset is as follows:

[[ 10 15 25]

[ 20 25 45]

[ 30 35 65]

[ 40 45 85]

[ 50 55 105]

[ 60 65 125]

[ 70 75 145]

[ 80 85 165]

[ 90 95 185]]

The task is to use the last three time steps from each of the three time series as input to the model and predict the next time steps of each of the three time series as output.

For example, here's the X input:

[[10 15 25]

[20 25 45]

[30 35 65]]

And this is the y output:

[[ 40 45 85]

[ 50 55 105]]

The tutorial uses Encoder-Decoder structure, but I want apply Stacked LSTM structure similar to following Stacked LSTM example. But my output is the sequence of the sequence and I do not know how I can choose n_steps_out for the Dense layer.

model = Sequential()
model.add(LSTM(100, activation='relu', return_sequences=True,    input_shape=(n_steps_in, n_features)))
model.add(LSTM(100, activation='relu'))
model.add(Dense(n_steps_out))
model.compile(optimizer='adam', loss='mse')
# fit model
model.fit(X, y, epochs=200, verbose=0)

Because I see you used machinelearningmastery, I am directing you to the same tise, with a different code, maybe you didn't find it. https://machinelearningmastery.com/multivariate-time-series-forecasting-lstms-keras/ Basically what will help you is the "series_to_supervised" function from the beginning of the code. It creates lagged datasets and you can play arround with how many lags you want to have. Either that, or this: https://github.com/llSourcell/How-to-Predict-Stock-Prices-Easily-Demo/blob/master/lstm.py Here, you have an example of outputting a sequence. Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM