我正在尝试编写一种新方法来分析时间序列预测的预测。因此,我需要在(预测的)每个时间戳复制我学习的模型,或者将其重置为上一个点,并用不同的输入进行输入。
我使用:
我的网络:
model = Sequential()
model.add(GRU(100, return_sequences=True, stateful=True, batch_size=batchSize, input_shape=(x, y)))
model.add(Dropout(dropout))
model.add(GRU(units, return_sequences=False, stateful=True))
model.add(Dropout(dropout))
model.add(Dense(1, activation="linear", kernel_constraint=min_max_norm(min_value=-10)))
model.compile(loss='mean_squared_error', optimizer='nadam', metrics=['accuracy'])
目前唯一有效的方法是从头开始预测先前的步骤:
for i in range(timestamps):
for j, features in enumerate(featuresTable[i]):
if i > 0:
model.predict(np.reshape(featuresList[:i], (i, 1, featuresList.shape[1])),
batch_size=self.batch_size)
predict = model.predict(np.reshape(features, (1, 1, len(features))), batch_size=self.batch_size)
model.reset_states()
其中timestamps
是时间戳的数量,featuresTable
是具有每个时间戳的替代功能的表,而featuresList
是正常功能
我想要什么:
state = getState(model)
for i in range(timestamps):
for j, features in enumerate(featuresTable[i]):
predict = model.predict(np.reshape(features, (1, 1, len(features))), batch_size=self.batch_size)
setState(model,state)
model.predict(np.reshape(featuresList[i], (1, 1, featuresList.shape[1])), batch_size=self.batch_size)
state = getState(model)
先谢谢你 〜Lifree