My Notebook running wothout errors in Collab but Coursera Grader Output shows failure

While running the notebook I get the error message as below:
There was a problem compiling the code from your notebook. Details: cannot reshape array of size 7840 into shape (27455,28,28,1)

It runs fine on Collab. Could you please help me submit to get the pass grade?

Please click my name and message your notebook / link to colab.

Thanks for your reply. Sent the link.

Please don’t hardcode the shapes when using reshape inside train_val_generators. Use np.expand_dims or get the array shape and then add 1 to the last dimension.
On a somewhat related note, for this assignment, you should use atmost 2 conv layers.

Thanks for the guidance. It helped me pass the assignment.
Also, with 2 levels of convolution I got 99% Training and Validation Accuracy.
Could you please explain how do we choose the level of Convolution Layers?

Choosing the number of convolution layers is part of a process called hyperparameter tuning. Here’s a good place to start

1 Like

Hi, I had the same problem and when I made the change you suggested I am getting this error in the following (grader) cell: “maximum supported dimension for an ndarray is 32, found 27455”

Also, I tried the below trying to debug:
When I use: np.expand_dims(…) → I get: (27455, 28, 28, 1)
When I use: np.reshape(…xx…,(27455, 28, 28,1)) → it works as expected
But when I do: np.reshape(…xx…,np.expand_dims(…)) → I get the same error as above

I’d appreciate if you can help me find the issue.

is not required.

Do see this as well.

Got it! Thanks