tensorflow tutorials(八):手写数字数据集MNIST介绍
来源:互联网 发布:是linux添加环境变量 编辑:程序博客网 时间:2024/06/08 08:58
声明:版权所有,转载请联系作者并注明出处: http://blog.csdn.net/u013719780?viewmode=contents
在做机器学习相关实验的时候,首先我们就是需要一份通用的数据集,以便与其他的算法得到的实验结果进行比较。在图像分类领域MNIST数据集就是这样一个通用的数据集,前面几篇博文都用到了MNIST数据集,本文对其进行一些简单的介绍!
In [1]:
import numpy as npimport tensorflow as tfimport matplotlib.pyplot as pltfrom tensorflow.examples.tutorials.mnist import input_data%matplotlib inline print ("packs loaded")
In [2]:
print ("Download and Extract MNIST dataset")mnist = input_data.read_data_sets('/tmp/data/', one_hot=True)printprint (" tpye of 'mnist' is %s" % (type(mnist)))print (" number of trian data is %d" % (mnist.train.num_examples))print (" number of test data is %d" % (mnist.test.num_examples))
In [3]:
# What does the data of MNIST look like? print ("What does the data of MNIST look like?")trainimg = mnist.train.imagestrainlabel = mnist.train.labelstestimg = mnist.test.imagestestlabel = mnist.test.labelsprintprint (" type of 'trainimg' is %s" % (type(trainimg)))print (" type of 'trainlabel' is %s" % (type(trainlabel)))print (" type of 'testimg' is %s" % (type(testimg)))print (" type of 'testlabel' is %s" % (type(testlabel)))print (" shape of 'trainimg' is %s" % (trainimg.shape,))print (" shape of 'trainlabel' is %s" % (trainlabel.shape,))print (" shape of 'testimg' is %s" % (testimg.shape,))print (" shape of 'testlabel' is %s" % (testlabel.shape,))
In [4]:
# How does the training data look like?print ("How does the training data look like?")nsample = 5randidx = np.random.randint(trainimg.shape[0], size=nsample)for i in randidx: curr_img = np.reshape(trainimg[i, :], (28, 28)) # 28 by 28 matrix curr_label = np.argmax(trainlabel[i, :] ) # Label plt.matshow(curr_img, cmap=plt.get_cmap('gray')) plt.title("" + str(i) + "th Training Data " + "Label is " + str(curr_label)) print ("" + str(i) + "th Training Data " + "Label is " + str(curr_label))
In [5]:
# Batch Learning? print ("Batch Learning? ")batch_size = 100batch_xs, batch_ys = mnist.train.next_batch(batch_size)print ("type of 'batch_xs' is %s" % (type(batch_xs)))print ("type of 'batch_ys' is %s" % (type(batch_ys)))print ("shape of 'batch_xs' is %s" % (batch_xs.shape,))print ("shape of 'batch_ys' is %s" % (batch_ys.shape,))
In [6]:
# Get Random Batch with 'np.random.randint'print ("5. Get Random Batch with 'np.random.randint'")randidx = np.random.randint(trainimg.shape[0], size=batch_size)batch_xs2 = trainimg[randidx, :]batch_ys2 = trainlabel[randidx, :]print ("type of 'batch_xs2' is %s" % (type(batch_xs2)))print ("type of 'batch_ys2' is %s" % (type(batch_ys2)))print ("shape of 'batch_xs2' is %s" % (batch_xs2.shape,))print ("shape of 'batch_ys2' is %s" % (batch_ys2.shape,))
In [7]:
randidx
Out[7]:
1 0
- tensorflow tutorials(八):手写数字数据集MNIST介绍
- TensorFlow学习笔记(3)--实现Softmax逻辑回归识别手写数字(MNIST数据集)
- tensorflow mnist手写数字(三)从零开始
- Tensorflow测试Mnist手写数据集
- tensorflow-mnist手写数字识别
- Tensorflow实例:mnist手写数字
- 经典手写数字mnist数据集识别
- 使用tensorflow利用神经网络分类识别MNIST手写数字数据集
- 利用tensorflow一步一步实现基于MNIST 数据集进行手写数字识别的神经网络,逻辑回归
- 使用tensorflow利用神经网络分类识别MNIST手写数字数据集,转自随心1993
- Tensorflow深度学习笔记(五)--手写数字识别-MNIST数据测试
- 【TensorFlow】TensorFlow实现 AlexNet Mnist手写数据集
- TensorFlow学习笔记(3)----CNN识别MNIST手写数字
- TensorFlow学习笔记(二)MNIST手写数字识别
- 基于Tensorflow的MNIST手写数字识别(一)
- 基于Tensorflow的MNIST手写数字识别(三)
- 用tensorflow实现MNIST(手写数字识别)
- TensorFlow代码实现(一)[MNIST手写数字识别]
- mysql 启动时找不到PID 进程坏死的问题
- 信号函数sigaction说明
- 用createQuery还是createSQLQuery?HQL和SQL的区别
- 常见的命令
- C# 编辑时获取datagridview的cell内容
- tensorflow tutorials(八):手写数字数据集MNIST介绍
- if __name__ 技巧
- JavaScript 运行机制详解:再谈Event Loop
- RabbitMQ使用总结:持久化
- Java服务器调优
- javaScript实现网页表格打印功能
- RabbitMQ使用场景练习:STOMP plugin
- 棋盘覆盖。大数
- VMware常用命令