mnist 数据集中的图片预览

active python3 env:      
    virtualenv -p /usr/bin/python3 py3env

读取mnist数据集:
import tensorflow as tf
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()

取出第一个数字图片28*28矩阵:
p1 = x_train[0] 

通过Pillow库PIL进行图片显示:
from PIL import Image
img = Image.fromarray(p1)
img.show(28,28)

第一个数字的真实值是5:
y_train[0]  












你可能感兴趣的:(mnist 数据集中的图片预览)