1

我过去使用 9 个特征和 18 个时间步来预测未来的 3 个值:

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

我的代码是:

# 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)

模型看起来像这样

恐怕问题出在这条线上:

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

我得到的错误是:

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

关于如何正确实施这一点的任何想法?

4

0 回答 0