TensorFlow新手实例源码--mnist源码
来源:互联网 发布:减少睡眠时间知乎 编辑:程序博客网 时间:2024/06/01 08:49
环境:python3.5(今[2017.11.25]实测3.6版本无法安装tensorflow)
以下源码已测试通过,准确率约91%
代码如下:
import tensorflow.examples.tutorials.mnist.input_data as input_datamnist = input_data.read_data_sets("MNIST_data/", one_hot=True)import tensorflow as tfx = tf.placeholder(tf.float32, [None, 784])W = tf.Variable(tf.zeros([784,10]))b = tf.Variable(tf.zeros([10]))y = tf.nn.softmax(tf.matmul(x,W) + b)y_ = tf.placeholder(tf.float32, [None,10])cross_entropy = -tf.reduce_sum(y_*tf.log(y))train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy)with tf.Session() as sess: sess.run(tf.global_variables_initializer()) for i in range(1000): batch_xs, batch_ys = mnist.train.next_batch(100) sess.run(train_step, feed_dict={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, "float")) print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels})) print(sess.run(W)) print(sess.run(b))
阅读全文
0 0
- TensorFlow新手实例源码--mnist源码
- [06]tensorflow源码例子mnist源码——mnist.py
- tensorflow源码例子mnist源码——mnist.py
- 读MNIST源码(二):tensorflow基础
- [07]tensorflow源码例子mnist源码——fully_connected_feed.py
- tensorflow源码例子mnist源码——fully_connected_feed.py
- TensorFlow+MNIST实例讲解
- Tensorflow-MNIST入门实例
- 自动下载和安装 MNIST 到 TensorFlow 的 python 源码
- TensorFlow手写数字识别mnist example源码分析
- Tensorflow实例:mnist手写数字
- Tensorflow实例:mnist最佳实践
- tensorflow笔记1——自动下载和安装 MNIST 到 TensorFlow 的 python 源码
- TensorFlow教程04:针对机器学习初学者的MNIST实验——源码和运行结果
- TensorFlow 从入门到精通(二):MNIST 例程源码分析
- TensorFlow教程06:MNIST的CNN实现——源码和运行结果
- TensorFlow教程06:MNIST的CNN实现——源码和运行结果
- TensorFlow入门01:MNIST分类的源码及关键函数解析
- redis性能调优一则
- java 8大数据类型
- 计算机基础学习资料整理和推荐
- 在VMware虚拟机中安装CentOS 7(图文教程)
- android faster screencap
- TensorFlow新手实例源码--mnist源码
- MySQL笔记
- 米联开发板资料链接
- Xcode9 iOS11模拟器和真机 APP图标不显示问题
- Webshell的小艺术
- JavaScript学习(一):弱类型
- (一)多线程快速入门
- 【CS231n_2017】1-Introduction to CNN for Visual Recognition
- weblogic Session共享