当前位置:网站首页>MNIST机器学习入门
MNIST机器学习入门
2022-08-09 10:39:00 【qq_26391203】
http://wiki.jikexueyuan.com/project/tensorflow-zh/tutorials/mnist_beginners.html
import tensorflow.examples.tutorials.mnist.input_data as input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
import tensorflow as tf
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("float", [None,10])
cross_entropy = -tf.reduce_sum(y_*tf.log(y))
train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy)
init = tf.initialize_all_variables()
sess = tf.Session()
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_: 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})
运行结果:
边栏推荐
猜你喜欢
分类预测 | MATLAB实现CNN-LSTM(卷积长短期记忆神经网络)多特征分类预测
[贴装专题] 贴装流程中涉及到的位置关系计算
【原创】解决阿里云oss-browser.exe双击没反应打不开,提供一种解决方案
笔记本电脑使用常见问题,持续更新
shell脚本实战(第2版)/人民邮电出版社 脚本2 验证输入:仅限字母和数字
Loop nesting and basic operations on lists
批量转换经纬度的网页实现方法
Oracle数据库常用函数总结
使用cpolar远程连接群晖NAS(创建临时链接)
Probably 95% of the people are still making PyTorch mistakes
随机推荐
stimulus.js 初体验
[贴装专题] 基于多目视觉的手眼标定
xmms播放器加了播放列表的管理功能
Electron application development best practices
今天做了手机播放器的均衡器
判断一段文字的width
一键完成物联网产品注册,快速体验在线调试设备
强化学习 (Reinforcement Learning)
[Halcon&定位] 解决Roi区域外的模板匹配成功
Unix Environment Programming Chapter 14 14.8 Memory Mapped I/O
MySQL执行过程及执行顺序
分类预测 | MATLAB实现CNN-GRU(卷积门控循环单元)多特征分类预测
Oracle数据库:for update 和for update nowait的区别
多行省略和选择器
Shell script combat (2nd edition) / People's Posts and Telecommunications Press Script 2 Validate input: letters and numbers only
xmms已经发布到v1.3了,好久没写博客了
[贴装专题] 视觉贴装平台与贴装流程介绍
unix环境编程 第十五章 15.10 POSIX信号量
遇到恶意退款不用怕,App 内购买项目的退款通知现已可用
阿里神作!吃透这份资料入厂率高达99%