0

There is an excellent post regarding time series encoder/decoder models here: How to include future values in a time series prediction of a RNN in Keras

I am trying to extend this to use three categories of features that have different sequence lengths.

  1. Co-variates with no future forecast
  2. Forecasted co-variates with very high correlation for next 24 hours only
  3. Forecasted co-variates with lower correlation for next 72 hours
Encoder Func
def encoder(hist_features):
    y, state_h, state_c = LSTM(units=pred_seq_length, return_state=True, return_sequences=False)(hist_features)
    return [y, state_h, state_c]
Decoder Func
def decoder(forecast_features_1, forecast_features_2, encoder_states):
    encoder_outputs = RepeatVector(pred_seq_length)(encoder_states[0])
    x1 = Concatenate(axis=-1)([forecast_features_1, encoder_outputs])
    x1 = LSTM(units=pred_seq_length, return_sequences=True)(x1, initial_state=encoder_states[1:])
    x1 = TimeDistributed(Dense(units=10, activation='relu'))(x1)
    x2 = LSTM(units=pred_seq_length, return_sequences=True)(forecast_features_2)
    x2 = TimeDistributed(Dense(units=pred_seq_length, activation='relu'))(forecast_features_2)
    y = Concatenate(axis=0)([x1, x2])
    y = TimeDistributed(Dense(units=1))(y)
    return y
Model Building
encoder_features = Input(shape=X_encoder.shape[1:])
decoder_features_1 = Input(shape=X_decoder_1.shape[1:])
decoder_features_2 = Input(shape=X_decoder_2.shape[1:])
encoder_outputs = encoder(encoder_features)
decoder_outputs = decoder(decoder_features_1, decoder_features_2, encoder_outputs)
model = Model([encoder_features, decoder_features_1, decoder_features_2], decoder_outputs)
Error Message
ValueError: A `Concatenate` layer requires inputs with matching shapes except for the concatenation axis. Received: input_shape=[(None, 72, 10), (None, 24, 72)]

I'm looking for advice on merging an accurate 24 prediction with a less accurate 72 hour prediction to make a unified 72 hour prediction.

The input sizes are Encoder -> (7808, 96, 23) 4 (or more) days of encoder inputs with 22 features and the target Decoder_1 -> (7808, 72, 22) 3 days of low correlation decoder input with 22 features and no target Decoder_2 -> (7808, 24, 1) 1 day of highly correlated decoder input with 1 feature

0 Answers0