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

2019-08-20 22:41发布

问题:

Not able to reshape the image in mnist dataset using sklean This is the starting portion of my code just load the data

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

ERROR PART

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)

回答1:

You can only reshape it into a 8, 8 array. 8x8=64



回答2:

try:

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