在学习Tensorflow时,很多例子都是采用的mnist数据集,首先是下载mnist数据集,下载地址如下:

http://www.tensorfly.cn/tfdoc/tutorials/mnist_download.html

将链接中四个压缩文件都下载下来,

Tensorflow学习--识别mnist数据集

如下图所示

Tensorflow学习--识别mnist数据集

然后四个压缩文件都放入一个新建的MNIST_data文件夹,不用解压直接放入文件夹就好了。 

 Tensorflow学习--识别mnist数据集

这里的数据集文件夹和写代码的文件是同一路径,方便读取,如果不是同一路径,在读取数据集的时候记得写全路径。如:

Tensorflow学习--识别mnist数据集

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/",one_hot=True)

print("输入数据:",mnist.train.images)
print("输入数据打印shape:",mnist.train.images.shape)

import pylab#图形打印类
im = mnist.train.images[1]
im = im.reshape(-1,28)
pylab.imshow(im)
pylab.show()

print("输入数据打印shape",mnist.test.images.shape)
print("输入数据打印shape",mnist.validation.images.shape)

运行效果如下

 Tensorflow学习--识别mnist数据集

 

 

相关文章:

  • 2021-09-06
  • 2021-10-08
  • 2021-11-04
  • 2021-08-28
  • 2021-10-13
  • 2021-11-30
  • 2021-05-30
  • 2021-09-27
猜你喜欢
  • 2021-07-04
  • 2021-11-06
  • 2021-09-18
  • 2021-08-01
  • 2021-08-08
  • 2021-09-23
  • 2019-06-01
相关资源
相似解决方案