【Mnist】用matplotlib查看Mnist数据集中的图片(由keras导入的数据集)
8行代码:
import numpy as np
import matplotlib.pyplot as plt
from keras.datasets import mnist
(X_train, Y_train), (Y_test, Y_test) = mnist.load_data() # 用过keras的都懂
indexs = 10 # X_train中60000张,想看哪张可以改
plt.imshow(X_train[indexs]) # 展示图片(28, 28)大小的
plt.title(str(Y_train[indexs])) # 标题是对应的标签
plt.show()
效果(jupyter notebook中):

plt.imshow()也可以展示多通道图片。

博客介绍了在jupyter notebook中,plt.imshow()可用于展示多通道图片的效果。
&spm=1001.2101.3001.5002&articleId=95401677&d=1&t=3&u=ab6b1d2240d142fca775a53c5853ac63)
847

被折叠的 条评论
为什么被折叠?



