tensorflow30《TensorFlow实战》笔记-03 TensorFlow第一步 code
来源:互联网 发布:天津大学软件下载 编辑:程序博客网 时间:2024/06/03 21:51
《TensorFlow实战》给出了很多论文和源码链接地址
InteractiveSession用法
# 《TensorFlow实战》03 TensorFlow第一步# win10 Tensorflow1.0.1 python3.5.3# CUDA v8.0 cudnn-8.0-windows10-x64-v5.1# filename:sz03.01.py # 神经网络# https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/mnist/mnist_softmax.py# 关于mnist的一些测试用例,可以参看 tensorflow\tensorflow\examples\tutorials\mnist 目录内容import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets("MNIST_data/", one_hot=True)print(mnist.train.images.shape, mnist.train.labels.shape)print(mnist.test.images.shape, mnist.test.labels.shape)print(mnist.validation.images.shape, mnist.validation.labels.shape)x = 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_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)sess = tf.InteractiveSession()tf.global_variables_initializer().run()for _ in range(1000): batch_xs, batch_ys = mnist.train.next_batch(100) #sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys}) train_step.run({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})) print(accuracy.eval({x: mnist.test.images, y_: mnist.test.labels}))'''(55000, 784) (55000, 10)(10000, 784) (10000, 10)(5000, 784) (5000, 10)0.40750.40290.4927...0.9070.91750.91850.91880.91830.91940.9172'''
0 0
- tensorflow30《TensorFlow实战》笔记-03 TensorFlow第一步 code
- tensorflow35《TensorFlow实战》笔记-06-03 TensorFlow实现 GoogleInceptionV3 code
- tensorflow32《TensorFlow实战》笔记-05 TensorFlow实现卷积神经网络 code
- tensorflow33《TensorFlow实战》笔记-06-01 TensorFlow实现AlexNet code
- tensorflow34《TensorFlow实战》笔记-06-02 TensorFlow实现VGGNet code
- tensorflow36《TensorFlow实战》笔记-06-04 TensorFlow实现 ResNet code
- tensorflow37《TensorFlow实战》笔记-07-01 TensorFlow实现Word2Vec code
- tensorflow44《TensorFlow实战》笔记-09-03 分布式并行 code
- tensorflow26《TensorFlow实战Google深度学习框架》笔记-10-03 分布式TensorFlow code
- tensorflow39《TensorFlow实战》笔记-07-03 TensorFlow实现Bidirectional LSTM Classifier code
- Tensorflow 实战 笔记
- tensorflow 实战笔记
- tensorflow42《TensorFlow实战》笔记-09-01 TensorBoard code
- tensorflow43《TensorFlow实战》笔记-09-02 多GPU并行 code
- tensorflow31《TensorFlow实战》笔记-04 TensorFlow实现自编码器及多层感知机 code
- tensorflow38《TensorFlow实战》笔记-07-02 TensorFlow实现基于LSTM的语言模型 code
- tensorflow40《TensorFlow实战》笔记-08-01 TensorFlow实现深度强化学习-策略网络 code
- tensorflow41《TensorFlow实战》笔记-08-02 TensorFlow实现深度强化学习-估值网络 code
- 被说了很多遍的设计模式---享元模式
- spring boot与kafka集成(spring boot 1.5.1版本)
- Java虚拟机JVM性能优化(一):JVM知识总结
- windows下Call to undefined function curl_init() error问题
- 经典排序算法
- tensorflow30《TensorFlow实战》笔记-03 TensorFlow第一步 code
- sqoop --split-by详解
- MySQL
- 使用jdbc连接oracle数据库
- 跟我一起学openGL-第一个三角形
- 封装的好处
- java程序:数据类型 流程控制语句 操作符
- MySQL
- iOS开发笔记(5) -- 推送证书的创建及合并