import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
img = x_train[0]
label = y_train[0]
print(label)
print(img.shape)
def img_show(image):
... plt.imshow(image)
... plt.axis('off') # Hide axes
... plt.show()
img_show(img)
展开/折叠结果
>>> print(label)
5
>>> print(img.shape)
(28, 28)

发表评论