Tensorflow学习系列(1)——MNIST手写识别
来源:互联网 发布:飞翔的小鸟游戏源码 编辑:程序博客网 时间:2024/06/05 11:37
代码:
import tensorflow as tfimport tensorflow.examples.tutorials.mnist.input_data as input_datamnist = input_data.read_data_sets("MNIST_data/",one_hot=True)x =tf.placeholder(tf.float32,[None,784])y_actual = tf.placeholder(tf.float32,[None,10])W =tf.Variable(tf.zeros([784,10])) b =tf.Variable(tf.zeros([10])) y_predict =tf.nn.softmax(tf.matmul(x,W)+b)cross_entropy =tf.reduce_mean(-tf.reduce_sum(y_actual*tf.log(y_predict),reduction_indices=1))train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)correct_prediction = tf.equal(tf.argmax(y_predict,1),tf.argmax(y_actual,1))accuracy =tf.reduce_mean(tf.cast(correct_prediction,tf.float32))init = tf.global_variables_initializer()with tf.Session() as sess: sess.run(init) for i in range(1000): batch_xs,batch_ys =mnist.train.next_batch(100) sess.run(train_step,feed_dict={x:batch_xs,y_actual:batch_ys}) if(i%100==0): print(accuracy.eval({x:mnist.test.images,y_actual:mnist.test.labels}))
结果:
0 0
- Tensorflow学习系列(1)——MNIST手写识别
- Tensorflow学习系列(2)——MNIST手写识别(多层网络)
- 《学习Tensorflow》——MNIST手写数字识别
- TensorFlow实战—mnist手写数字识别
- tensorflow笔记(四)之MNIST手写识别系列一
- tensorflow笔记(四)之MNIST手写识别系列一
- tensorflow笔记(五)之MNIST手写识别系列二
- tensorflow笔记(五)之MNIST手写识别系列二
- Tensorflow MNIST 手写识别
- TensorFlow学习笔记(3)----CNN识别MNIST手写数字
- TensorFlow学习笔记(二)MNIST手写数字识别
- TensorFlow学习---实现mnist手写数字识别
- tensorflow入门实践例子—MNIST手写数字识别
- Tensorflow #1 祖传例子 MNIST 手写识别
- tensorflow-mnist手写数字识别
- 【TensorFlow】神经网络MNIST手写识别
- Caffe学习总结(三)——mnist手写字库识别例程(1)
- Tensorflow系列之(二):详解CNN识别MNIST手写数字集
- GDOI2017模拟 Round 4 4.24-4.26
- C#easyui实现增删改查
- 3ds Max 2014插件安装(插件无效的原因~)
- 决策树
- Android XML解析方式
- Tensorflow学习系列(1)——MNIST手写识别
- struts2中简单的文件上传
- python学习笔记7.5-内建模块struct
- SurfaceFlinger启动过程分析(一)、(二)、(三)、(四)【转】
- 使用原生js实现ajax请求
- Android-性能优化之内存泄漏(二)
- php运算优先级情况
- Qt下写一个简单的加法计算界面
- android 开发错误集