Following a similar question, I have a problem where I need to predict many steps ahead of 3 different time series. I managed to generate a network that given the past 7 values of 3 time series as input, predicts 5 future values for one of them. The input x
has these dimensions:
(500, 7, 3): 500 samples, 7 past time steps, 3 variables/time series)
The target y
has these dimensions:
(500, 5): 500 samples, 5 future time steps
The LSTM network is defined as:
model = Sequential()
model.add(LSTM(input_dim=3, output_dim=10, return_sequences=True))
model.add(Dropout(0.2))
model.add(LSTM(50))
model.add(Dropout(0.2))
model.add(Dense(input_dim=10, output_dim=7))
model.add(Activation('linear'))
model.compile(loss='mae', optimizer='adam')
What if now I want to predict the values of 2 time series?
I tried the following code:
inputs = Input(shape=(7,3)) # 7 past steps and variables
m = Dense(64,activation='linear')(inputs)
m = Dense(64,activation='linear')(m)
outputA = Dense(1,activation='linear')(m)
outputB = Dense(1,activation='linear')(m)
m = Model(inputs=[inputs], outputs=[outputA, outputB])
m.compile(optimizer='adam', loss='mae')
m.fit(x,[y1,y2])
Where both y1
and y2
have the same dimensions as y
(500, 5). But I obtain the following error:
"Error when checking target: expected dense_4 to have 3 dimensions, but got array with shape (500, 5)".
How should I reshape y1
and y2
? Or should I have a different structure for the network?