我已经训练了一个模型:
trainX = trainX.reshape(1, 43164, 17)
trainY = trainY.reshape(43164, 1)
model = Sequential()
model.add(LSTM(2, input_shape=(43164, 17)))
model.add(Dense(1))
model.compile(loss='mean_squared_error', optimizer='adam')
model.fit(trainX, trainY[0], epochs=100)
testX.shape # (8633, 17)
testX = testX.reshape(1, 8633, 17)
当我对此数据进行预测时,我得到了一个错误:
Error when checking input: expected lstm_26_input to have shape (43164, 17)
but got array with shape (8633, 17)
我该怎么做才能获得良好的效果?
答案 0 :(得分:3)
在深度学习网络的Sequential modesls中,您可以在窗口有限的情况下以有限的短窗口传递数据,或者
使用一维向量传递所有序列
trainX = trainX.reshape( 43164,1, 17)
trainY = trainY.reshape(43164, 1)
model = Sequential()
model.add(LSTM(2, input_shape=(1, 17)))
model.add(Dense(1))
model.compile(loss='mean_squared_error', optimizer='adam')
model.fit(trainX, trainY[0], epochs=100)
testX.shape # (8633, 17)
testX = testX.reshape(8633,1, 17)