我试图建立一个LSTM神经网络,训练和测试数据集如下:
x_train=np.array(train)
x_train=x_train.reshape(51,77,6)
y_train=list(train.Close[1:])
y_train.append(train.Close[-1])
y_train=np.array(y_train).reshape(51,77)
x_test=np.array(test)
x_test=x_test.reshape(1,77, 6)
y_test=list(test.Close[1:])
y_test.append(test.Close[-1])
y_test=np.array(y_test)
LSTM网络代码为
BATCH_SIZE = 1
TIME_STEP = 77
FEATURES = 6
model = Sequential()
model.add(LSTM(64,input_shape=(TIME_STEP, FEATURES),return_sequences=True))
model.add(LSTM(32))
model.add(Dense(1, activation="softmax"))
model.compile(loss="binary_crossentropy",
optimizer="adam",
metrics=['accuracy'])
model.summary()
[![][[1]][1] 当我尝试使用
model.fit(x_train, y_train,
batch_size=BATCH_SIZE,
nb_epoch=15,
validation_data=(x_test, y_test))
score, acc = model.evaluate(x_test, y_test, batch_size=batch_size)
为了训练模型,它返回
ValueError: Error when checking target: expected dense_24 to have shape (1,) but got array with shape (77,)
我曾尝试更改输入训练集维度,但它仍会返回如下错误
目前没有回答
相关问题 更多 >
编程相关推荐