【发布时间】:2020-05-20 02:05:23
【问题描述】:
所以我想创建一个 lstm 网络以在我的数据上运行,但我收到以下消息:
ValueError: 检查输入时出错:预期 lstm_1_input 的形状为 (None, 1) 但得到的数组的形状为 (1, 557)
这是我的代码:
x_train=numpy.array(x_train)
x_test=numpy.array(x_test)
x_train = numpy.reshape(x_train, (x_train.shape[0], 1, x_train.shape[1]))
x_test = numpy.reshape(x_test, (x_test.shape[0], 1, x_test.shape[1]))
# create and fit the LSTM network
model = Sequential()
model.add(LSTM(50, input_shape=(1,len(x_train[0]) )))
model.add(Dense(1))
model.add(Dropout(0.2))
model.compile(loss='mean_squared_error', optimizer='adam')
model.fit(x_train, numpy.array(y_train), epochs=100, batch_size=1, verbose=2)
【问题讨论】:
标签: python arrays machine-learning keras lstm