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


    训练数据量的大小对深度学习结果有重要影响,前面(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

     混淆矩阵:

    
    
  • 相关阅读:
    致远OA-A8协同管理软件无需登录getshell漏洞
    WordPress插件NextGEN Gallery <= 3.2.2 RCE漏洞利用(需要登录)
    Coremail邮件系统配置文件泄露漏洞
    CVE-2019-12735 VIM命令执行漏洞利用
    分享一个乌云Drops文章在线浏览的网站
    Ubuntu、Debian安装Docker CE
    一些好用的网络渗透工具和查询平台
    CVE-2017-11882 Office内存损坏漏洞利用
    Cobalt Strike入门教程-通过exe木马实现远控
    Jfinal cms前台评论XSS漏洞分析
  • 原文地址:https://www.cnblogs.com/zhengbiqing/p/11768706.html
Copyright © 2020-2023  润新知