weixin_45099845 2019-07-25 20:24 采纳率: 50%
浏览 9705
已采纳

如何防止过拟合?为何我的训练准确率高,但是测试准确率很低?

问题如标题
print('Training ------------')

training the model

model.fit(X_train, y_train, epochs=8, batch_size=32,)

Epoch 1/8
19578/19578 [==============================] - 334s 17ms/step - loss: 1.9936 - acc: 0.3272
Epoch 2/8
19578/19578 [==============================] - 325s 17ms/step - loss: 1.3145 - acc: 0.5698
Epoch 3/8
19578/19578 [==============================] - 325s 17ms/step - loss: 0.9667 - acc: 0.6897
Epoch 4/8
19578/19578 [==============================] - 325s 17ms/step - loss: 0.7580 - acc: 0.7557
Epoch 5/8
19578/19578 [==============================] - 325s 17ms/step - loss: 0.5882 - acc: 0.8095
Epoch 6/8
19578/19578 [==============================] - 325s 17ms/step - loss: 0.4548 - acc: 0.8510
Epoch 7/8
19578/19578 [==============================] - 325s 17ms/step - loss: 0.3471 - acc: 0.8839
Epoch 8/8
19578/19578 [==============================] - 325s 17ms/step - loss: 0.2524 - acc: 0.9176

print('\nTesting ------------')

Evaluate the model with the metrics we defined earlier

loss, accuracy = model.evaluate(X_test1, y_test1)

print('\ntest loss: ', loss)
print('\ntest accuracy: ', accuracy)

Testing ------------
3000/3000 [==============================] - 16s 5ms/step

test loss: 15.392780853271484

test accuracy: 0.045

  • 写回答

2条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥20 苹果app名字侵权商标,我投诉了,但是苹果一直没回怎么办
      • ¥15 Android studio运行不成功总是报错
      • ¥15 pycharm 加载软件包列表时出错connect timed out
      • ¥15 和您碰到了同一个问题
      • ¥15 如何在微信支付V3PHP版请求中添加header?
      • ¥15 在数字信号处理中用MATLAB显示波形。
      • ¥15 keil MDK软件进行仿真调试的局限
      • ¥15 关于gateway产生临时文件夹的问题
      • ¥15 Java Broken Pipe以及OOM
      • ¥20 请问有没有RTL8211FS的参考原理图