tensorflow 入门小例子(mnist手写数字识别)
来源:互联网 发布:wap页面纯文字游戏源码 编辑:程序博客网 时间:2024/05/22 01:57
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
# 定义算法公式,即神经网络的前向计算
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
sess=tf.InteractiveSession()
x=tf.placeholder(tf.float32,shape=[None,784])
w=tf.Variable(tf.random_uniform([784,10],-1,1))
b=tf.Variable(tf.zeros([10]))
y=tf.nn.softmax(tf.matmul(x,w)+b)
# 定义损失函数且选定优化算法,并将指定优化器优化loss
y_=tf.placeholder(tf.float32,shape=[None,10])
cross_entrypy=tf.reduce_mean(-tf.reduce_sum(y_*tf.log(y),reduction_indices=[1]))
train_step=tf.train.GradientDescentOptimizer(0.5).minimize(cross_entrypy)
tf.global_variables_initializer().run()
# 迭代的对数据进行训练
for i in range(1000):
batch_xs,batch_ys=mnist.train.next_batch(100)
sess.run(train_step,{x:batch_xs,y_:batch_ys})
# 在测试集上进行评估
correct_prediction=tf.equal(tf.argmax(y,1),tf.argmax(y_,1))
accuracy=tf.reduce_mean(tf.cast(correct_prediction,tf.float32))
print sess.run(accuracy,feed_dict={x:mnist.test.images,y_:mnist.test.labels})
以上是tensor flow入门的例子,其正确率只有百分之就是一点几。
- tensorflow 入门小例子(mnist手写数字识别)
- tensorflow入门实践例子—MNIST手写数字识别
- Tensorflow入门 mnist手写数字识别
- tensorflow入门-mnist手写数字识别(一)
- tensorflow-mnist手写数字识别
- 基于tensorflow的MNIST手写数字识别--入门篇
- tensorflow的入门--手写数字识别mnist的傻瓜教程
- 基于tensorflow的MNIST手写数字识别(二)--入门篇
- Tensorflow #1 祖传例子 MNIST 手写识别
- TensorFlow学习笔记(3)----CNN识别MNIST手写数字
- TensorFlow学习笔记(二)MNIST手写数字识别
- 基于Tensorflow的MNIST手写数字识别(一)
- 基于Tensorflow的MNIST手写数字识别(三)
- 用tensorflow实现MNIST(手写数字识别)
- TensorFlow代码实现(一)[MNIST手写数字识别]
- TensorFlow实战-mnist手写数字识别(卷积神经网络)
- 基于tensorflow的MNIST手写数字识别
- 基于tensorflow的MNIST手写数字识别
- IDEA 循环依赖解决方法
- Ruby中的Hash哈希类型基本操作方法小结
- 多线程下载(断点下载)java代码
- 生活和异端·《乖摸摸头》·三
- 02-线性结构2 一元多项式的乘法与加法运算(20 分)
- tensorflow 入门小例子(mnist手写数字识别)
- [App] Squid 代理缓存服务器安装
- Ubuntu 17.10安装sklearn
- c++基础知识
- [LeetCode] 669.Trim a Binary Search Tree
- 版本控制之git命令行大全(分支教程)
- Spring-Session源码研究之processRequest
- 【UI设计】4、RecycleView的使用
- struts2的<s:property />的使用