【问题标题】:Predicting with different time step with a model trained for different time step data使用针对不同时间步长数据训练的模型进行不同时间步长的预测
【发布时间】:2019-10-04 23:49:50
【问题描述】:

我已经用 3 个时间步训练了我的 LSTM。以下是 Keras LSTM 层。

model.add(LSTM(32, return_sequences=True, input_shape=(None, 3))).

例如:

   X                           Y
   [[1,2,3],[2,3,4],[4,5,6]]   [[4],[5],[7]]

现在我需要预测具有不同 time_steps 的序列的下一个值(例如:2)

  X= [[1,2]]

当我使用X= [[1,2]] 时出现以下错误

ValueError: Error when checking input: expected lstm_1_input to have shape (None, 3) 
but got array with shape (1, 2)

我是否应该在用于训练时提供相同的形状。

或者我仍然可以使用不同的时间步长(输入形状)进行预测。

感谢您在此问题上的帮助。

【问题讨论】:

    标签: keras lstm


    【解决方案1】:

    我相信您在使用模型预测新数据时需要使用相同的形状。您的数据使用 3 个时间步 (train_X) 进行了训练,因此您应该在建模时为其提供 3 个时间步的输入。预测您的测试数据 (test_X)。

    【讨论】:

      猜你喜欢
      • 2022-01-14
      • 1970-01-01
      • 2019-01-09
      • 2021-08-07
      • 2023-03-07
      • 1970-01-01
      • 2021-01-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多