Pratik patil
Pratik patil

Reputation: 1

ValueError: cannot reshape array of size 60000 into shape (60000,784)

trainX = trainX.reshape((trainX.shape[0],28*28)).astype('float32') trainy = trainy.reshape((trainy.shape[0],28*28)).astype('float32')

Error is - ValueError Traceback (most recent call last) <ipython-input-91-537b84233ef5> in <module>() 1 trainX = trainX.reshape((trainX.shape[0],28*28)).astype('float32') ----> 2 trainy = trainy.reshape((trainy.shape[0],28*28)).astype('float32')

ValueError: cannot reshape array of size 60000 into shape (60000,784)

Upvotes: 0

Views: 1264

Answers (1)

Gerry P
Gerry P

Reputation: 8092

What it is telling you is trainX has 60000 elements. Before you try to resize it do

print (trainX.shape)

this will give you the actual dimension of trainX at the outset. when you reshape remember that the product of the dimensions of the reshaped array must match the product of the dimensions of the original array. In other words they have to have the same number of elements

Upvotes: 1

Related Questions