使用BP神经网络进行深度学习时,在训练时获得平坦的误差曲线

问题描述 投票:0回答:1

在使用传统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)

错误图:

enter image description here

Error plot with reduced learning rate

python neural-network deep-learning prediction backpropagation
1个回答
0
投票

如果没有关于数据的更多信息,很难评估,您可以共享样本吗?但我猜测你的模型很快就会过度使用。你可以尝试的事情:

  • 模型简化 - 尝试删除一个图层,或使用较少的单位作为初学者
  • 不同的优化器,尝试不同学习率的sgd
  • 不同的指标(尝试逐个删除)
© www.soinside.com 2019 - 2024. All rights reserved.