在使用传统BP神经网络进行深度学习的同时,我总是得到平曲线的误差图。我正在使用带有Adam优化器的Keras顺序模型。 NN在培训和测试方面的总体准确率为80%。任何人都可以解释为什么误差曲线是平的(见附图)?还有什么方法可以改善我的结果吗?
def build_model():
model = keras.Sequential()
model.add(layers.Dense(128, activation=tf.nn.relu, input_shape=len(normed_train_data.keys())]))
model.add(layers.Dense(128,activation=tf.nn.relu, input_shape=(1,)))
model.add(layers.Dense(4))
model.compile(loss='mean_squared_error', optimizer='Adam',metrics=['mae', 'mse','accuracy'])
return model
def plot_history(history):
hist = pd.DataFrame(history.history)
hist['epoch'] = history.epoch
plt.figure()
plt.xlabel('Epoch')
plt.ylabel('Mean Abs Error [per]')
plt.plot(hist['epoch'], hist['mean_absolute_error'],label='Train Error')
plt.plot(hist['epoch'], hist['val_mean_absolute_error'],label = 'Val Error')
plt.legend()
plt.ylim([0,200])
plt.show()
而在主要功能,
model = build_model()
model.summary()
history = model.fit(normed_train_data, train_labels,epochs=EPOCHS,validation_split = 0.2, verbose=0,callbacks=[PrintDot()])
hist = pd.DataFrame(history.history)
hist['epoch'] = history.epoch
plot_history(history)
错误图:
如果没有关于数据的更多信息,很难评估,您可以共享样本吗?但我猜测你的模型很快就会过度使用。你可以尝试的事情: