Tensorflow Mnist数据集
发布时间:2020-12-16 06:28:27 所属栏目:asp.Net 来源:网络整理
导读:Tensorflow自带的Mnist数据集相关情况 import tensorflow as tfimport numpy as npimport matplotlib.pyplot as pltfrom tensorflow.examples.tutorials.mnist import input_data#数据会自动在线下载,第一次较慢,第二次之后就好了mnist = input_data.read_
Tensorflow自带的Mnist数据集相关情况
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data #数据会自动在线下载,第一次较慢,第二次之后就好了 mnist = input_data.read_data_sets(‘data/‘,one_hot=True) print(type(mnist)) print(mnist.train.num_examples)#55000 print(mnist.test.num_examples)#10000 img_train = mnist.train.images label_train = mnist.train.labels img_test = mnist.test.images label_test = mnist.test.labels print(type(img_train))#<class ‘numpy.ndarray‘> print(type(label_train))#<class ‘numpy.ndarray‘> print(type(img_test))#<class ‘numpy.ndarray‘> print(type(label_test))#<class ‘numpy.ndarray‘> print(img_train.shape)#(55000,784) 28*28的图片 print(label_train.shape)#(55000,10) print(img_test.shape)#(10000,784) print(label_test.shape)#(10000,10) #one hot coding便于取最大概率 num_sample = 5 rand_idx = np.random.randint(img_train.shape[0],size=num_sample) for i in rand_idx: cur_img = np.reshape(img_train[i,:],(28,28)) cur_label = np.argmax(label_train[i,:]) plt.matshow(cur_img,cmap = plt.get_cmap(‘gray‘)) print(str(i) + "训练数据的标签是" + str(cur_label)) # plt.show() #取batch数据 batch_size = 100 batch_x,batch_y = mnist.train.next_batch(batch_size) print(type(batch_x))#<class ‘numpy.ndarray‘> print(type(batch_y))#<class ‘numpy.ndarray‘> print(batch_x.shape)#(100,784) print(batch_y.shape)#(100,10) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ASP.Net Webforms和ASP.Net MVC是基于组件还是基于动作?
- iis – Perfmon:哪个计数器标识线程正在等待?
- 使用WCAT对ASP.NET / IIS进行压力测试
- asp.net-web-api – 如何在Azure Service Fabric中的自托管
- asp.net – 最佳AJAX框架
- asp.net-mvc – 可以在桌面应用程序开发中使用MVC设计模式/
- 如何配置asp.net进程在域帐户下运行?
- asp.net – 黑客正试图在我们的某个网站上做某事
- asp.net-mvc – 从Visual Studio 2015中完全删除Applicatio
- asp.net – HtmlGenericControl(“br”)呈现两次
推荐文章
站长推荐
- ASP.NET调试与IIS超时
- asp.net – 请求URL在IIS 7中无效
- asp.net – ApplicationInsight导致网站在启动时
- asp.net-mvc – 为服务层设计DI(构造函数注入)的
- asp.net – asp mvc http以对象作为参数获取动作
- razor – ASP.NET Core中当前上下文中不存在名称
- asp.net-mvc-3 – 动态地为每个列的ASP.NET MVC
- asp.net – Windows身份验证会话超时
- asp.net-mvc-4 – WebApi Json.NET自定义日期处理
- asp.net-mvc – ASP.NET MVC:如何绑定List类型的
热点阅读