gpt4 book ai didi

machine-learning - 时间序列的 LSTM

转载 作者:行者123 更新时间:2023-11-30 09:49:29 25 4
gpt4 key购买 nike

我正在尝试使用 LSTM 构建预测模型;使用系列“数据”简要预测“目标”。经过几个时期后,它正确地拟合了数据。作为初学者,什么样的数据集 (尺寸)我必须要饲料 网带,为了给我进一步的预测?

我的目标是预测 +1 步,给定整个过去的时间序列,我该如何实现它?

最终,当我 reshape “数据”和“目标”时,第二个 1 代表什么?



print(df.head)
0 7 20
1 0 0
2 0 0
3 0 0
4 0 0
...

data = df[:,0]
target = df[:, 1 ]

data = data.reshape((1, 1, int(len(df))))
target = target.reshape((1 ,1, int(len(df))))
#We Define The Model
import random
random.seed(1)

model = Sequential()
model.add(LSTM(int(len(df)), input_shape=(1, int(len(df))), return_sequences=True))
model.add(Dense(int(len(df))))

model.add(LSTM(int(len(df)), input_shape=(1, int(len(df))), return_sequences=True))
model.add(Dense(int(len(df))))

model.compile(loss='mean_absolute_error', optimizer='Adam',metrics=['accuracy'])

model.fit(data, target, nb_epoch=100, batch_size=1, verbose=2, validation_data = (data, target))

predict = model.predict(data)

最佳答案

我认为您正在使用 Keras 开发您的 LSTM 模型。我建议您查看以下链接(如下),以更仔细地了解为什么需要 reshape 数据。在示例中,您的数据框的尺寸与教程使用的尺寸相同。

https://machinelearningmastery.com/time-series-prediction-lstm-recurrent-neural-networks-python-keras/

关于machine-learning - 时间序列的 LSTM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47581373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com