〇、前情提要
在b站跟着up主 白手起家的百万富翁 学mnist手写体识别实践。
参考:
- 【mnist手写体识别实践】想知道手写体识别如何做吗?跟美女算法专家一起了解mnist数据集 并用python实践手写体识别吧
https://www.bilibili.com/video/BV1YJ41137jy/?spm_id_from=333.788.videocard.0 - minist数据集 - THE MNIST DATABASE of handwritten digits
http://yann.lecun.com/exdb/mnist/ - 我的笔记- 【TensorFlow】mac下出现from tensorflow.examples.tutorial.mnist import input_data无法导入
https://blog.csdn.net/weixin_43210113/article/details/107671454 - 我的笔记-【TensorFlow】解决AttributeError: module ‘scipy.misc‘ has no attribute ‘toimage‘问题
https://blog.csdn.net/weixin_43210113/article/details/107673559 - AttributeError: module ‘tensorflow’ has no attribute 'placeholder’等问题的解决
https://blog.csdn.net/flowingfog/article/details/93597697?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param
一、写在前面
up的简介
之前一直讲算法理论,本期视频带大家用python动手实践mnist数据集,简单了解mnist数据集并进行手写体识别实践,希望可以让大家从最简单的入门,慢慢进入人工智能领域,我的初衷就是希望能帮助想进入人工智能领域的朋友快速了解AI,我所有视频的ppt都会发在专栏里,如果大家喜欢,请关注我,并点赞转发弹幕评论投币哦~ 如果非常喜欢我的话,请给我充电哦~我会一直更新的,你们的支持是我最大的动力
其他
目前做机器学习python,深度学习TensorFlow、Keras,用的softmax函数,一层神经网络的形式。
准备工作
下载
- train-images-idx3-ubyte.gz: training set images (9912422 bytes)
- train-labels-idx1-ubyte.gz: training set labels (28881 bytes)
- t10k-images-idx3-ubyte.gz: test set images (1648877 bytes)
- t10k-labels-idx1-ubyte.gz: test set labels (4542 bytes)
二、读入数据集并查看格式
一些提示
如果无法导入from tensorflow.examples.tutorials.mnist import input_data
,可以看我写的笔记:
我的笔记- 【TensorFlow】mac下出现from tensorflow.examples.tutorial.mnist import input_data无法导入
https://blog.csdn.net/weixin_43210113/article/details/107671454
one_hot
one_hot是分类问题必用的一种手段
数字一共10类,就把
0转成(1,0,0,0,0,0,0,0,0,0),
1转成(0,1,0,0,0,0,0,0,0,0),
2转成(0,0,1,0,0,0,0,0,0,0),
…
这样可以匹配最后softmax层维数
下载数据集
# 如果tensorflow版本为1用第一种 版本为2用第二种
import tensorflow as tf
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
# 使用mnist数据集,要引用读取方式
from tensorflow.examples.tutorials.mnist import input_data
# from tensorflow.contrib.learn.python.learn.datasets.mnist import read_da