Trouble running the exact same code in PyCharm

Hi guys,

Thank you for the great course content. Parallel to doing the exercises on Google Colab, I am running the exercises on my computer. I have bumped into a very odd error when I run the convolutional neural network exercise on my computer. The error reads thusly: “Error when checking input: expected conv2d_input to have shape (28, 28, 1) but got array with shape (60000, 28, 28)”.

I have no idea why the exact same code runs without a problem on google colab notebook but not in PyCharm.
Could you guys by any chance help me with this?
The code is in the third block of C1_W3_Lab_1_improving_accuracy_using_convolutions.ipynb notebook.

Thanks in advance.

You should reshape the training data to (60000, 28, 28, 1). While greyscale is obvious to us, the TF needs to see it as a separate channel. Use x = x.reshape(60000, 28, 28, 1)


Thanks balaji! That indeed solved the problem.

That may have solved the runtime problem, but it didn’t answer the question asked, which was why it runs on colab but not in a PyCharm editor. Is it a package version difference? Seems like kind of a big change.