Keras培训为什么在验证精度保持不变的情况下提高培训准确性?

时间:2018-07-12 15:33:01

标签: neural-network keras conv-neural-network

我正在使用Keras训练两层一维CNN模型,其输入和输出功能为softmax,SGD / adam优化器,但我看到训练精度提高了,而验证精度保持不变或围绕相同数字旋转。 为什么会发生这种情况?

74336/74336 [==============================] - 64s 863us/step - loss: 0.3306 - acc: 0.9096 - val_loss: 0.6093 - val_acc: 0.8473
Epoch 2/30
74336/74336 [==============================] - 62s 840us/step - loss: 0.1980 - acc: 0.9464 - val_loss: 0.6631 - val_acc: 0.8235
Epoch 3/30
74336/74336 [==============================] - 63s 849us/step - loss: 0.1678 - acc: 0.9537 - val_loss: 0.5885 - val_acc: 0.8493
Epoch 4/30
74336/74336 [==============================] - 64s 859us/step - loss: 0.1497 - acc: 0.9591 - val_loss: 0.6043 - val_acc: 0.8482
Epoch 5/30
74336/74336 [==============================] - 64s 865us/step - loss: 0.1407 - acc: 0.9611 - val_loss: 0.5922 - val_acc: 0.8454
Epoch 6/30
74336/74336 [==============================] - 67s 900us/step - loss: 0.1292 - acc: 0.9644 - val_loss: 0.6744 - val_acc: 0.8275
Epoch 7/30
74336/74336 [==============================] - 67s 906us/step - loss: 0.1215 - acc: 0.9669 - val_loss: 0.6556 - val_acc: 0.8381
Epoch 8/30
74336/74336 [==============================] - 69s 929us/step - loss: 0.1170 - acc: 0.9676 - val_loss: 0.6184 - val_acc: 0.8510
Epoch 9/30
74336/74336 [==============================] - 70s 943us/step - loss: 0.1120 - acc: 0.9692 - val_loss: 0.6888 - val_acc: 0.8372
Epoch 10/30
74336/74336 [==============================] - 75s 1ms/step - loss: 0.1097 - acc: 0.9696 - val_loss: 0.7360 - val_acc: 0.8438
Epoch 11/30
74336/74336 [==============================] - 96s 1ms/step - loss: 0.1045 - acc: 0.9714 - val_loss: 0.6840 - val_acc: 0.8277
Epoch 12/30
74336/74336 [==============================] - 87s 1ms/step - loss: 0.1024 - acc: 0.9720 - val_loss: 0.6362 - val_acc: 0.8450
Epoch 13/30
74336/74336 [==============================] - 89s 1ms/step - loss: 0.1003 - acc: 0.9722 - val_loss: 0.7576 - val_acc: 0.8129
Epoch 14/30
74336/74336 [==============================] - 94s 1ms/step - loss: 0.0964 - acc: 0.9735 - val_loss: 0.7404 - val_acc: 0.8366
Epoch 15/30
74336/74336 [==============================] - 73s 985us/step - loss: 0.0949 - acc: 0.9739 - val_loss: 0.6569 - val_acc: 0.8369
Epoch 16/30
74336/74336 [==============================] - 74s 998us/step - loss: 0.0918 - acc: 0.9749 - val_loss: 0.7587 - val_acc: 0.8225
Epoch 17/30
74336/74336 [==============================] - 72s 971us/step - loss: 0.0885 - acc: 0.9754 - val_loss: 0.7721 - val_acc: 0.8438
Epoch 18/30
74336/74336 [==============================] - 74s 990us/step - loss: 0.0866 - acc: 0.9761 - val_loss: 0.6615 - val_acc: 0.8338
Epoch 19/30
74336/74336 [==============================] - 76s 1ms/step - loss: 0.0858 - acc: 0.9767 - val_loss: 0.6973 - val_acc: 0.8348
Epoch 20/30
74336/74336 [==============================] - 75s 1ms/step - loss: 0.0835 - acc: 0.9771 - val_loss: 0.6497 - val_acc: 0.8274
Epoch 21/30
74336/74336 [==============================] - 72s 972us/step - loss: 0.0825 - acc: 0.9769 - val_loss: 0.6922 - val_acc: 0.8339
Epoch 22/30
74336/74336 [==============================] - 73s 977us/step - loss: 0.0814 - acc: 0.9776 - val_loss: 0.7579 - val_acc: 0.7976
Epoch 23/30
74336/74336 [==============================] - 73s 978us/step - loss: 0.0801 - acc: 0.9775 - val_loss: 0.7615 - val_acc: 0.8093
Epoch 24/30
74336/74336 [==============================] - 73s 977us/step - loss: 0.0790 - acc: 0.9784 - val_loss: 0.7847 - val_acc: 0.8308
Epoch 25/30
74336/74336 [==============================] - 63s 853us/step - loss: 0.0780 - acc: 0.9780 - val_loss: 0.6529 - val_acc: 0.8472
Epoch 26/30
74336/74336 [==============================] - 61s 818us/step - loss: 0.0750 - acc: 0.9795 - val_loss: 0.6955 - val_acc: 0.8195
Epoch 27/30
74336/74336 [==============================] - 64s 858us/step - loss: 0.0749 - acc: 0.9788 - val_loss: 0.8086 - val_acc: 0.8407
Epoch 28/30
74336/74336 [==============================] - 58s 780us/step - loss: 0.0722 - acc: 0.9800 - val_loss: 0.7252 - val_acc: 0.8318
Epoch 29/30
74336/74336 [==============================] - 55s 742us/step - loss: 0.0720 - acc: 0.9799 - val_loss: 0.7773 - val_acc: 0.8251
Epoch 30/30
74336/74336 [==============================] - 63s 845us/step - loss: 0.0733 - acc: 0.9797 - val_loss: 0.6815 - val_acc: 0.8275

2 个答案:

答案 0 :(得分:1)

可能是您的模型实际收敛了。尝试通过reduceLROnplateau

降低学习率

答案 1 :(得分:0)

验证损失减少,而训练损失则减少。这表明可能过度拟合。减少过度拟合的几件事:

  • 添加辍学
  • 数据扩充-随机移动,修剪和旋转应足够
  • 使用较小的模型
  • 使用L2权重正则化和权重衰减