我试图调和我对LSTM的理解,并在克里斯托弗·奥拉在克拉拉斯实施的这篇文章中指出.我正在关注Jason Brownlee为Keras教程撰写的博客.我主要困惑的是,
[samples, time steps, features]和,让我们参考下面粘贴的代码集中讨论上述两个问题:
# reshape into X=t and Y=t+1
look_back = 3
trainX, trainY = create_dataset(train, look_back)
testX, testY = create_dataset(test, look_back)
# reshape input to be [samples, time steps, features]
trainX = numpy.reshape(trainX, (trainX.shape[0], look_back, 1))
testX = numpy.reshape(testX, (testX.shape[0], look_back, 1))
########################
# The IMPORTANT BIT
##########################
# create and fit the LSTM network
batch_size = 1
model = Sequential()
model.add(LSTM(4, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Keras中的多变量LSTM进行多步时间序列预测.具体来说,我最初每个时间步有两个变量(var1和var2).在这里遵循在线教程后,我决定在时间(t-2)和(t-1)使用数据来预测时间步t的var2的值.如示例数据表所示,我使用前4列作为输入,Y作为输出.我可以在这里看到我开发的代码,但我有三个问题.
var1(t-2) var2(t-2) var1(t-1) var2(t-1) var2(t)
2 1.5 -0.8 0.9 -0.5 -0.2
3 0.9 -0.5 -0.1 -0.2 0.2
4 -0.1 -0.2 -0.3 0.2 0.4
5 -0.3 0.2 -0.7 0.4 0.6
6 -0.7 0.4 0.2 0.6 0.7
Run Code Online (Sandbox Code Playgroud)