【发布时间】:2018-05-22 12:49:19
【问题描述】:
我正在使用 mnist 数据集并想一次绘制一些数字。该数据集为我提供了形状为(784, ) 的数组,并表示一个 28x28 像素的图像。
假设我想在 2x2 网格中绘制 4 个数字。该网格的形状应为(2*28, 2*28)。这是我想要的结果:
+---+---+
| 0 | 9 |
+---+---+
| 9 | 0 |
+---+---+
这是我的代码:
zero # an array from the mnist dataset
nine # another array from the mnist dataset
zero.shape
#(784,)
nine.shape
#(784,)
x = np.stack([zero, nine, zero, nine])
x.shape
# (4, 784)
imshow(x.reshape(2*28, 2*28))
show()
【问题讨论】:
标签: python numpy reshape mnist