【发布时间】:2017-07-10 06:29:15
【问题描述】:
我正在使用 tensorflow 导入一些 MNIST 输入数据。我按照这个教程...https://www.tensorflow.org/get_started/mnist/beginners
我正在导入它们......
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)
我希望能够显示训练集中的任何图像。我知道图片的位置是mnist.train.images,所以我尝试访问第一张图片并像这样显示它......
with tf.Session() as sess:
#access first image
first_image = mnist.train.images[0]
first_image = np.array(first_image, dtype='uint8')
pixels = first_image.reshape((28, 28))
plt.imshow(pixels, cmap='gray')
我尝试将图像转换为 28 x 28 numpy 数组,因为我知道每个图像都是 28 x 28 像素。
但是,当我运行代码时,我得到的只是以下内容......
显然我做错了什么。当我打印出矩阵时,一切看起来都不错,但我认为我错误地重塑了它。
【问题讨论】:
标签: python numpy matplotlib tensorflow mnist