自學筆記:顯示mnist官方數據的的圖片和標籤

#python 3.6
import  numpy as np
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import matplotlib.pyplot as plt
index=3 #第幾張圖,隨便寫
mnist=input_data.read_data_sets('/tmp/data/', one_hot=True)
image=np.reshape(mnist.train.images[index],[28,-1])
print(mnist.train.labels[index])  #顯示label
plt.imshow(image, cmap=plt.get_cmap('gray_r'))  #畫圖
plt.show()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章