Week3_Assignment_Getting Error in Pre-processing the data

Hello! I hope you are doing well.

Getting error in reshape_and_normalize

My approach is:
x = x. reshape(28,28,1)

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

What mistake am I making?

Reshape is meant to arrange elements of an nd-array based on your specification. Since 28*28*1 != 47040000, this error is raised. You need to specify 1 more dimension to make this work.

1 Like

Thank you, Balaji, for your prompt reply.

I just checked that training_images shape is (60000, 28, 28). So, we have 60000 images, and each image has shape (28,28) before the reshape_and_normalize function and (28,28,1) after the reshape_and_normalize,right?

It seems like you are working on course 1 week 3 assignment. If so, please fix the topic title. Here’s the community user guide to get started.

See the expected output of the next cell that follows the reshape_and_normalize function.
Shape of training set after reshaping: (60000, 28, 28, 1)

I changed it. By mistake, I chose course 2, instead of 1. Thanks for correcting me.