码迷,mamicode.com
首页 > 其他好文 > 详细

Keras猫狗大战五:采用全部数据集训练,精度提高到90%

时间:2019-10-31 00:26:23      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:tor   poc   kaggle   amp   keras   ati   com   pre   get   

深度学习严重依赖训练数据量的大小,前面(https://www.cnblogs.com/zhengbiqing/p/11070783.html)只随机抽取猫狗图片各1000、500、200分别作为训练、验证、测试集,即使采用了数据增强,精度只达到83%。

采用kaggle 猫狗数据集全部25000张进行训练学习,随机选取猫狗图片各9000、2250、1250分别作为训练、验证、测试集,进行训练。

训练100次迭代:

history = model.fit_generator(
    train_generator,
    steps_per_epoch=train_generator.samples // batch_size,
    epochs=100,
    validation_data=validation_generator,
    validation_steps=validation_generator.samples // batch_size)
Epoch 1/100
281/281 [==============================] - 140s 498ms/step - loss: 0.6736 - acc: 0.5683 - val_loss: 0.6532 - val_acc: 0.6074
Epoch 2/100
281/281 [==============================] - 74s 262ms/step - loss: 0.6358 - acc: 0.6310 - val_loss: 0.5861 - val_acc: 0.6803
Epoch 3/100
281/281 [==============================] - 73s 261ms/step - loss: 0.6094 - acc: 0.6625 - val_loss: 0.5559 - val_acc: 0.7146
Epoch 4/100
281/281 [==============================] - 73s 261ms/step - loss: 0.5936 - acc: 0.6807 - val_loss: 0.5511 - val_acc: 0.7216
Epoch 5/100
281/281 [==============================] - 73s 260ms/step - loss: 0.5797 - acc: 0.6918 - val_loss: 0.5308 - val_acc: 0.7347
Epoch 6/100
281/281 [==============================] - 73s 261ms/step - loss: 0.5681 - acc: 0.7018 - val_loss: 0.5318 - val_acc: 0.7356
......
Epoch 96/100
281/281 [==============================] - 74s 264ms/step - loss: 0.2963 - acc: 0.8717 - val_loss: 0.3118 - val_acc: 0.8614
Epoch 97/100
281/281 [==============================] - 74s 263ms/step - loss: 0.2983 - acc: 0.8726 - val_loss: 0.2581 - val_acc: 0.8862
Epoch 98/100
281/281 [==============================] - 74s 263ms/step - loss: 0.2936 - acc: 0.8781 - val_loss: 0.2546 - val_acc: 0.8922
Epoch 99/100
281/281 [==============================] - 74s 263ms/step - loss: 0.3047 - acc: 0.8711 - val_loss: 0.2548 - val_acc: 0.8884
Epoch 100/100
281/281 [==============================] - 74s 263ms/step - loss: 0.3013 - acc: 0.8744 - val_loss: 0.2745 - val_acc: 0.8848

训练曲线:

技术图片

技术图片

用测试集对模型进行测试:

test_generator = test_datagen.flow_from_directory(
    test_dir,
    target_size=(150, 150),
    batch_size=batch_size,
    class_mode=binary)

test_loss, test_acc = model.evaluate_generator(test_generator, steps=test_generator.samples // batch_size)
print(test acc:, test_acc)
Found 2500 images belonging to 2 classes.
test acc: 0.9

 混淆矩阵:

技术图片

Keras猫狗大战五:采用全部数据集训练,精度提高到90%

标签:tor   poc   kaggle   amp   keras   ati   com   pre   get   

原文地址:https://www.cnblogs.com/zhengbiqing/p/11768706.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!