- 首页 > it技术 > >
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets('./data/mnist_data', one_hot=True)i = 0
# 获取图片
image = mnist.train.images[i]
# 将图像数据还原成28*28的分辨率
image = image.reshape(28, 28)
# 打印对应的标签
answer = np.argmax(mnist.train.labels[i])
plt.imshow(image,cmap='binary')
title = 'No.'+str(i-int('0'))+': '+str(answer-int('0'))
plt.title(title)
plt.show()
推荐阅读