I'm working on a multivariate time series forecasting problem where I have 2 features and 15 time steps and I want to predict one/two future values. My data set shapes are as follows:
Training Shape: (2063, 15, 2) (2063, 1)
Testing Shape: (259, 15, 2) (259, 1)
Prediction Shape: (65, 15, 2) (65, 1)
I have the following LSTM model:
def mylstm(structure , data):
inputs = Input(shape=(data["X_train"].shape[1],data["X_train"].shape[2]))
lstm_1 = LSTM(structure["n_hidden_units"], return_sequences=True,
activation=structure["activation"],
kernel_initializer=structure["network_weight_initial"])(inputs)
lstm_out=LSTM(structure["n_hidden_units"])(lstm_1)
outputs = Dense(1)(lstm_out)
model = Model(inputs=inputs, outputs=outputs)
model.summary()
return model
optimizer = getattr(optimizers, structure["opt"])(learning_rate=structure["learning_rate"])
model.compile(optimizer=optimizer, loss='mse')
history = model.fit(
data["X_train"], data["y_train"], epochs=structure["epoch"],
batch_size=structure["batch_size"], verbose=2,
validation_data=(X_valid, y_valid), shuffle=False,
)
After training the model and calling the predict function as follows
y_pred = model.predict(data["X_test"])
I get the error message:
ValueError: y_true and y_pred must have the same number of dimensions.
That's because y_pred is 1820 length (65*14*2). I cannot figure out why it considers the batch size, I was supposed to get 65*2 dimensions but it gives 1820*1.