python - 如何在keras中使用MNIST数据集显示图像

标签 python matplotlib keras

我从 keras 导入了 minst 数据集,并希望显示其中的一些图像。但是由于我内部从keras导入数据集,我应该如何使用matplotlib来显示一些图像?

%matplotlib inline 

import matplotlib.pyplot as plt
import matplotlib.image as mpimg

# this creates a training set and test set
(x_train, y_train), (x_test, y_test) = mnist.load_data()

img=mpimg.imread('x_train[1]')
imgplot = plt.imshow(img)
plt.show()

Screenshot from Keras library

最佳答案

你可以这样做

import matplotlib.pyplot as plt
image=x_train[1]
plt.imshow(image)
plt.show()

关于python - 如何在keras中使用MNIST数据集显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50230222/

相关文章:

python - 使用不对称的自定义误差线按组制作seaborn.barplot

python - 如何使用 matplotlib 在 python 中制作梯形和平行四边形

python - Keras:在新实验中重复使用经过训练的权重

java - 如何在 tensorflow 图中查找操作名称

python - ValueError at/image/Tensor Tensor ("activation_5/Softmax:0", shape=(?, 4), dtype=float32) 不是这个图的元素

python - 为 numpy.array 的每个元素添加一个维度

python - 使用 Google 云函数写入 Google 云 Spanner 时出错

python - Pandas :聚合给定列的行并计算数量

python - 将 WXpython 位图转换为图像,然后再返回

linux - Python ImportError no module named statistics 下载后