摘 要:本文以MNIST 数据库为例,用TensorFlow 读取数据集中的数据,并建立一个简单的图像识别模型。同时以TensorFlow 为工具,写一个手写体数字识别程序,使用的机器方法是Softmax 回归。通过把占位符的值传递给会话,计算后运行梯度下降后,可以检测模型训练的结果,得到预测的标签和实际标签,接下来通过tf.equal 函数来比较它们是否相等,并将结果保存到correct_prediction 中。最后,用tf.reduce_mean 可以计算数组中的所有元素的平均值,相当于得到了模型的预测准确率。该模型识别的准确率超过90%,具有一定的推广价值。
关键词:MNIST 数据集;Softmax 回归;训练模型
中图分类号:TP181 文献标识码:A 文章编号:2096-4706(2019)12-0098-02
Application of TensorFlow to Read Data in Simple Image Recognition
LAI Xuewei
(College of Information and Media,Sanmenxia Polytechnic,Sanmenxia 472000,China)
Abstract:This paper takes the MNIST database as an example,uses TensorFlow to read the data in the data set,and establishes asimple image recognition model.At the same time with TensorFlow tool,write a handwritten number recognition program,using Softmaxregression. By passing the value of placeholder to the session,the result of model training can be detected after the gradient descent isrun after calculation,and the predicted tag and the actual tag can be obtained. Next,the equality function of tf.equal is used to comparewhether they are equal,and the result is saved in correct_prediction. Finally,tf.reduce_mean can be used to calculate the average valueof all elements in the array,which is equivalent to the prediction accuracy of the model.The recognition accuracy of the modified model ismore than 90%,which has a little promotion value.
Keywords:MNIST data set;Softmax regression;training model
参考文献:
[1] FesianXu. 在TensorFlow 中自定义梯度的两种方法 [EB/OL].https://blog.csdn.net/LoseInVain/article/details/83108001,2018-10-19.
[2] 束陈. 基于智能床垫的睡眠健康状况研究 [D]. 北京: 北京邮电大学,2018.
[3] BVL10101111. Deep Learning 之最优化方法 [EB/OL].https://blog.csdn.net/BVL10101111/article/details/72614711,2017-05-21.
[4] 高桥耕三,周广文. 静止卫星之间碰撞的概率及其避免方法 [J]. 国外导弹技术,1984(2):20-32.
作者简介:来学伟(1981-),男,汉族,河南灵宝人,工程硕士,讲师,主要研究方向:计算机软件开发与研究。