【发布时间】:2017-12-26 14:03:51
【问题描述】:
如果我通过以下方式下载 Keras 中的 CIFAR 10 图像:
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
# Getting shape
x_train.shape
>>> (50000, 32, 32, 3)
然后我可以通过以下方式绘制每个图像:
# Plot RGB image
plt.imshow(x_train[0])
# Plot only one colour-channel e.g. R
plt.imshow(x_train[0][:,:,0])
现在我通过 Keras 获得 MNIST 图像:
(X_train, y_train), (X_test, y_test) = mnist.load_data()
# getting shape
X_train.shape
>>> (60000, 28, 28)
但是它没有深度通道,它应该是 1,因为它是灰度的。如果我使用以下方法重塑它:
X_train = X_train.reshape(X_train.shape[0],28,28,1)
我可以让神经网络工作,但我不能再绘制它了。重塑它以便我仍然可以绘制的正确方法是什么?
【问题讨论】:
标签: python image-processing keras conv-neural-network