1

I am using 9 features and 18 time steps in the past to forecast 3 values in the future:

lookback = 18
forecast = 3
n_features_X = 9
n_features_Y = 1

My code is:

# Encoder
past_inputs = tf.keras.Input(shape=(lookback, n_features_X), name='past_inputs')
encoder = tf.keras.layers.LSTM(128, return_state=True)
encoder_outputs, state_h, state_c = encoder(past_inputs)

# Decoder
future_inputs = tf.keras.Input(shape=(forecast, n_features_Y), name='future_inputs')

decoder_lstm = tf.keras.layers.LSTM(128, return_sequences=True)
x = decoder_lstm(future_inputs, initial_state=[state_h, state_c])
output = tf.keras.layers.Dense(1, activation='linear')(x)

# Create the model
model = tf.keras.models.Model(inputs=[past_inputs, future_inputs], outputs=output)

The model looks like this

I am afraid the problem is with this line:

future_inputs = tf.keras.Input(shape=(forecast, n_features_Y), name='future_inputs')

The error I am getting is:

AssertionError: Could not compute output Tensor("dense_23/Identity:0", shape=(None, 3, 1), dtype=float32)

Any ideas on how to correctly implement this?

0 Answers0