【发布时间】:2019-08-05 06:48:41
【问题描述】:
我是一个新手,我只是尝试使用以下代码获得准确性并验证准确性
model = Sequential()
model.add(LSTM(10, input_shape=(train_X.shape[1], train_X.shape[2])))
#model.add(Dropout(0.2))
#model.add(LSTM(30, input_shape=(train_X.shape[1], train_X.shape[2])))
model.add(Dense(1), return_sequences=True)
model.compile(loss=’mae’, optimizer=’adam’, metrics=[‘accuracy’])
# fit network
history = model.fit(train_X, train_y, epochs=50, batch_size=120, validation_data=(test_X, test_y), verbose=2, shuffle=False)
# plot history
pyplot.plot(history.history[‘loss’], label=’train’)
pyplot.plot(history.history[‘val_loss’], label=’test’)
pyplot.legend()
pyplot.show()
print(history.history[‘acc’])
由于损失值非常低(约为 0.0136),尽管我得到的准确度为 6.9%,验证准确度分别为 2.3%,非常低
【问题讨论】:
标签: python machine-learning keras neural-network lstm