试图学习tensorflow的人啊。
来源:互联网 发布:ab测试 算法 编辑:程序博客网 时间:2024/06/05 01:03
试图学习tensorflow
光看(看的是 《TensorFlow实战_黄文坚》)是不行的,写了好几遍,终于可以闭着眼睛写出来了。
有几处是死记硬背,希望以后能理解吧。
编辑器是anaconda-spyder,简单无脑,不用搞环境还是好啊。
以下就是tensorflow 的”hello world“
代码块
# y = x * W + b #解释一下,x是输入 y是输出 目标是寻找出参数W和b,使得该等式成立(绝大多数情况下)# x [50000, 784] y [50000, 10] import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets("MNIST_data", one_hot=True) #获取数据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 i in range(1000): bat_x, bat_y_ = mnist.train.next_batch(100) train_step.run(feed_dict={x:bat_x, y_:bat_y_})accuracy = tf.reduce_mean(tf.cast(tf.equal(tf.arg_max(y, 1), tf.arg_max(y_, 1)), tf.float32))print(accuracy.eval(feed_dict={x:mnist.test.images, y_:mnist.test.labels}))
阅读全文
0 0
- 试图学习tensorflow的人啊。
- [TensorFlow] TensorFlow学习的方向
- Tensorflow 的初步学习
- 学习TensorFlow,生成tensorflow输入输出的图像格式
- UIView的试图切换
- 试图的优点
- 简单的试图3
- TensorFlow中CIFAR10的学习
- tensorflow学习存在的问题
- 【tensorflow学习】FeatureColumn 的作用
- 基于tensorflow的增强学习
- 迁移学习的TensorFlow实现
- TensorFlow 学习率的设置
- 深度学习的TensorFlow实现
- 学习tensorflow遇到的问题
- 【不捨弃的后果】太多人试图将应当…
- TensorFlow 学习-01-TensorFlow在虚拟机Ubuntu64bit上的安装
- TensorFlow 全网最全学习资料汇总之TensorFlow的技术应用
- java 并发编程实战书籍学习 第五章,CountDownLatch,FutureTask,CyclicBarrier,Semaphore学习
- 【c#系列 二】从java到.net 基础
- springcloud 总 架构图
- composer 安装laravel 框架
- 照片处理小工具三合一设计到实现(一)
- 试图学习tensorflow的人啊。
- 什么事数据对象以及属性分为什么类型?
- web错误代码
- Centos 6.5下安装Java
- 监听文件变化后合并文件
- spring boot 快速集成 mybatis
- Mybatis中if标签中的整型判断问题
- 3-4 计算长方形的周长和面积
- 软件开发流程