我正在用Keras构建LSTM用于时间序列预测,但我希望模型能够以小批量(窗口)进行训练并在线进行预测,如here所述 . 这是因为数据一次在一个数据记录中流式传输 . 例如,在窗口大小为500的情况下,在时间步长500处,模型将在步骤1-500上进行训练,并且现在将尝试预测501,然后是502,503等 . 直到时间步长1000,模型才会再次训练 .
但结果是奇怪的,其中预测值随着每个训练窗口而增加,如this plot所示 . 关于这里有什么问题的任何想法?
我有一个小架构:
layers = {'input': inputDims, 'hidden1': 35, 'hidden2': 35, 'output': 1}
model = Sequential()
model.add(LSTM(
input_length=self.sequenceLength,
input_dim=self.layers['input'],
output_dim=self.layers['hidden1'],
return_sequences=True)
model.add(Dropout(0.2))
model.add(LSTM(
self.layers['hidden2'],
return_sequences=False)
model.add(Dropout(0.2))
model.add(Dense(output_dim=self.layers['output']))
self.model.add(Activation('linear'))
model.compile(loss='mse', optimizer='rmsprop')
1 回答
这可能不是您的具体实现的问题,而是具有长时间序列的LSTM概念问题的化身 . 一个很好的起点是论文Learning to forget: Continual prediction with LSTM . 特别是,作者观察到了这一点
然后