TensorFlow入门测试程序
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data mnist=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) sess=tf.InteractiveSession()
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)
tf.initialize_all_variables().run() for i in range(1000):
batch_xs,batch_ys=mnist.train.next_batch(100)
train_step.run({x:batch_xs,y_:batch_ys}) correct_prediction=tf.equal(tf.arg_max(y,1),tf.arg_max(y_,1))
accuracy=tf.reduce_mean(tf.cast(correct_prediction,tf.float32)) print(accuracy.eval({x:mnist.test.images,y_:mnist.test.labels}))
运行结果:

TensorFlow入门测试程序的更多相关文章
- (转)TensorFlow 入门
TensorFlow 入门 本文转自:http://www.jianshu.com/p/6766fbcd43b9 字数3303 阅读904 评论3 喜欢5 CS224d-Day 2: 在 Da ...
- TensorFlow 入门之手写识别(MNIST) softmax算法
TensorFlow 入门之手写识别(MNIST) softmax算法 MNIST flyu6 softmax回归 softmax回归算法 TensorFlow实现softmax softmax回归算 ...
- FaceRank,最有趣的 TensorFlow 入门实战项目
FaceRank,最有趣的 TensorFlow 入门实战项目 TensorFlow 从观望到入门! https://github.com/fendouai/FaceRank 最有趣? 机器学习是不是 ...
- #tensorflow入门(1)
tensorflow入门(1) 关于 TensorFlow TensorFlow™ 是一个采用数据流图(data flow graphs),用于数值计算的开源软件库.节点(Nodes)在图中表示数学操 ...
- TensorFlow入门(五)多层 LSTM 通俗易懂版
欢迎转载,但请务必注明原文出处及作者信息. @author: huangyongye @creat_date: 2017-03-09 前言: 根据我本人学习 TensorFlow 实现 LSTM 的经 ...
- TensorFlow入门,基本介绍,基本概念,计算图,pip安装,helloworld示例,实现简单的神经网络
TensorFlow入门,基本介绍,基本概念,计算图,pip安装,helloworld示例,实现简单的神经网络
- [译]TensorFlow入门
TensorFlow入门 张量(tensor) Tensorflow中的主要数据单元是张量(tensor), 一个张量包含了一组基本数据,可以是列多维数据.一个张量的"等级"(ra ...
- 转:TensorFlow入门(六) 双端 LSTM 实现序列标注(分词)
http://blog.csdn.net/Jerr__y/article/details/70471066 欢迎转载,但请务必注明原文出处及作者信息. @author: huangyongye @cr ...
- TensorFlow入门(四) name / variable_scope 的使
name/variable_scope 的作用 欢迎转载,但请务必注明原文出处及作者信息. @author: huangyongye @creat_date: 2017-03-08 refer to: ...
随机推荐
- FTP批量下载数据文件
包含ftp的命令脚本,建立临时文件. ::服务器连接信息 set username=root set password=root set ip=xxx.xxx.xxx.xxx set RemoteDi ...
- C++——const
参考:https://www.cnblogs.com/Forever-Kenlen-Ja/p/3776991.html ; //修饰变量,a不能该内容(更改为其他的值) int* const p = ...
- parseXXX的用法
转换字符串. parseXXX是Integer类.等基本数据类型包装类的方法,用于实现String和int型数据的转换.例如, Integer.getInteger(String s) 从字符串中获取 ...
- python3-file的修改实现类似shell中sed的功能
# Auther: Aaron Fan '''思路:目的是为了修改yesterday这个文件,但是因为无法直接去修改这个文件,所以需要先把修改好的内容写入高yesterday.new这个文件中,然后再 ...
- Linux shell实现阳历转农历
闲来无事,想在Linux下用shell写一个阳历转农历的脚本,断断续续大概一个星期终于搞定.现在拿出来与大家分享. 缘由 本脚本实现原理是查表法(因为公式有误差):基于农历新年为基准,对农历新年前后两 ...
- C++的运算符重载 (转)
C++中预定义的运算符的操作对象只能是基本数据类型.但实际上,对于许多用户自定义类型(例如类),也需要类似的运算操作.这时就必须在C++中重新定义这些运算符,赋予已有运算符新的功能,使它能够用于特 ...
- 《Effective Java》第4章 类和接口
第13条:使类和成员的可访问性最小化 第一规则很简单:尽可能地使每个类或者成员不被外界访问.换句话说.应该使用与你正在编写的软件的对应功能相一致的.尽可能最小的访问级别. 对于顶层的(非嵌套的)类和接 ...
- jQuery+css实现tab功能
点击我我会消失 Click me 点击按钮我会消失,再点击我会出现 演示tab tab1 tab2 tab3 [环球时报记者 郭芳] “中国秘密发射新快速响应火箭”,25日,在中国官方媒体报道我国“快 ...
- go语言入门教程百度网盘 mysql图形化操作与数据导入
mysql图形化操作与数据导入 @author:Davie 版权所有:北京千锋互联科技有限公司 数据库存储技术 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库.每个数据库都有一个 ...
- Automake基本用法
一. 确认你的系统安装有GNU的如下软件: 1. automake2. autoconf3. m44. perl5. 如果你需要产生共享库(shared library)则还需要GNU Libtool ...