当前位置:网站首页>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})
运行结果: 
边栏推荐
猜你喜欢

985毕业,工作3年,分享从阿里辞职到了国企的一路辛酸和经验

编解码(seq2seq)+注意机制(attention) 详细讲解

浅析JWT安全问题
![[Error record] Solve the problem that ASRock J3455-ITX cannot be turned on without a monitor plugged in](/img/a9/d6aba07e6a4e1536cd10d91f274b2e.jpg)
[Error record] Solve the problem that ASRock J3455-ITX cannot be turned on without a monitor plugged in

对话跨国消费品牌DPO:数据安全合规从何做起?8.11直播见!
![[项目配置] 配置Qt函数库和ui界面库的封装并调用的项目](/img/e9/d41f144a2f27e76f97cd6401d37578.png)
[项目配置] 配置Qt函数库和ui界面库的封装并调用的项目

第二周作业

arcgis制图之天地图符号样式配置

深度学习--生成对抗网络(Generative Adversarial Nets)

【 original 】 VMware Workstation implementation Openwrt soft routing, the ESXI, content is very detailed!
随机推荐
常用语言图表库总结
[Halcon&几何] 直线的垂线与延长线的计算
上传张最近做的E2用的xmms的界面的截图
Solve the ali cloud oss - the original 】 【 exe double-click response can't open, to provide a solution
Umi Hooks
一键完成物联网产品注册,快速体验在线调试设备
分类预测 | MATLAB实现CNN-GRU(卷积门控循环单元)多特征分类预测
【 original 】 VMware Workstation implementation Openwrt soft routing, the ESXI, content is very detailed!
1003 我要通过! (20 分)
ESIM(Enhanced Sequential Inference Model)- 模型详解
By asking where the variables are stored, the shepherd boy laughed and said to use pointers, Go lang1.18 introductory refining tutorial, from Bai Ding to Hongru, the use of go lang type pointers (Poin
Probably 95% of the people are still making PyTorch mistakes
深度学习--神经网络(基础讲解)
pytorch widedeep文档
json库的dumps()方法和loads()方法
使用.NET简单实现一个Redis的高性能克隆版(四、五)
好久没更新博客了
Win32控件--------------------WM_DRAWITEM消息测试程序
Loop nesting and basic operations on lists
StratoVirt 中的虚拟网卡是如何实现的?