无法将大小为64的数组重塑为形状(28,28)

时间:2019-04-01 20:00:50

标签: python-3.x image machine-learning reshape mnist

无法使用Sklean重塑mnist数据集中的图像 这是我的代码的开始部分,只需加载数据

some_digit  =   X[880] 
some_digit_image = some_digit.reshape(28,   28)

错误部分

ValueError                                Traceback (most recent call last)
<ipython-input-15-4d618bdb57bc> in <module>
      1 some_digit = X[880]
----> 2 some_digit_image = some_digit.reshape(28,28)

ValueError: cannot reshape array of size 64 into shape (28,28)

2 个答案:

答案 0 :(得分:1)

您只能将其重塑为8、8阵列。 8x8 = 64

答案 1 :(得分:0)

尝试:

some_digit  =   X[880] 
some_digit_image = some_digit.reshape(8,   8)