0
votes

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)

1
Did you have a question?marcdtheking
I'd be surprised if the shape of your individual labels was 28*28. This is MNIST, isn't it?couka

1 Answers

1
votes

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