在一天的预测之前初始化LSTM状态

Ann*_*off 5 python lstm keras tensorflow

我想使用LSTM来预测每天强烈依赖季节的时间序列。作为测试数据,使用了不同季节的天数。在对测试数据进行预测之前,我想LSTM使用前一天的训练数据来初始化状态。

model = Sequential()
model.add(LSTM(hidden_size, input_shape=(sequence_size, inputs), return_sequences=True)
model.add(Dense(units=2)
model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])

for _ in range(100):
    model.fit(X_train, Y_train, batch_size=batch_size, epochs=1, validation_data=None, shuffle=True)
    for day in range(num_test_days):
        #TODO: initialize state of LSTM with the training data of previous day
        y_pred = model.predict(X_test[day].reshape(1, sequence_size, inputs), batch_size=1)
Run Code Online (Sandbox Code Playgroud)

#Todo源代码中所标记,我想LSTM为当天的预测做准备,以便使状态适合于预测考试日。有办法吗?