我的数据集有2944424行6列。我在Keras使用LSTM来预测出租车需求。我有问题的input_shape参数的最低限度。
它给出了错误:
ValueError: Error when checking input: expected lstm_15_input to have 3 dimension发布于 2019-06-16 18:03:38
输入应该是形状的(批次大小,步骤数,特性)。详情见以下内容:
https://machinelearningmastery.com/reshape-input-data-long-short-term-memory-networks-keras/
发布于 2019-06-16 16:08:45
下面的示例显示,通过打印火车数据的形状,您可以将正确的值传递给input_shape()。另外,这取决于您想要以2D或其他方式提供数据。从片段中可以看到:
trainX.shape[1]=10
trainX.shape[2]=1440
以及基于测试形状Dense(units = 960)的输出
#Shape of train and test data
trainX, testX, trainY, testY = train_test_split(trainX,trainY, test_size=0.2 , shuffle=False)
print("train size: {}".format(trainX.shape))
print("train Label size: {}".format(trainY.shape))
print("test size: {}".format(testX.shape))
print("test Label size: {}".format(testY.shape))
#train size: (23, 10, 1440)
#train Label size: (23, 960)
#test size: (6, 10, 1440)
#test Label size: (6, 960)
# create and fit the Simple LSTM model
#model_LSTM = Sequential()
model_LSTM.add(LSTM(units = 1440, input_shape=(trainX.shape[1], trainX.shape[2])))
model_LSTM.add(Dense(units = 960))编辑:以下基于此示例的提示可以帮助您为LSTM准备输入数据:
input_shape参数定义。input_shape参数由两个值组成,它们定义了时间步骤和特性的数量。reshape()函数在NumPy数组上可以用来重塑你的一维或二维数据为3D。reshape()函数将元组作为定义新形状的参数。https://datascience.stackexchange.com/questions/53896
复制相似问题