weixin_45099845
2019-07-25 20:24
采纳率: 60%
浏览 9.6k

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

问题如标题
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条回答 默认 最新

相关推荐 更多相似问题