Code Monkey home page Code Monkey logo

binary_classification_keras's Introduction

问题描述

要解决的是一个医学图像的二分类问题,有AKSK两种病症,根据一定量数据,进行训练,对图像进行预测。

给定图片数据的格式:

解决思路

整体上采用迁移学习来训练神经网络,使用InceptionV3结构,框架采用keras.

具体思路:

  1. 读取图片数据,保存成.npy格式,方便后续加载
  2. 标签采用one-hot形式,由于标签隐藏在文件夹命名中,所以需要自行添加标签,并保存到.npy文件中,方便后续加载
  3. 将数据分为训练集、验证集、测试集
  4. 使用keras建立InceptionV3基本模型,不包括顶层,使用预训练权重,在基本模型的基础上自定义几层神经网络,得到最后的模型,对模型进行训练
  5. 优化模型,调整超参数,提高准确率
  6. 在测试集上对模型进行评估,使用精确率、召回率
  7. 对单张图片进行预测,并输出每种类别的概率

代码结构

运行结果

1. 训练结果

2. 评估结果

3. 预测结果

知识点总结

  1. 如何加载实际数据,如何保存成npy文件,如何打乱数据,如何划分数据,如何进行交叉验证
  2. 如何使用keras进行迁移学习
  3. keras中数据增强、回调函数的使用,回调函数涉及:学习速率调整、保存最好模型、tensorboard可视化
  4. 如何使用sklearn计算准确率,精确率,召回率,F1_score
  5. 如何对单张图片进行预测,并打印分类概率
  6. 如何指定特定GPU训练,如何指定使用GPU的内存情况

binary_classification_keras's People

Contributors

jinghaiting avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.