I passed all tests, I tested the shape of all matrices and everything is apparently ok. But when I submitted my notebook Coursera graded me with a 0 score in exercise 3. The Coursera message is “There was a problem grading your submission. Details: cannot reshape array of size 220 into shape (55,4096)”, but I have checked the shapes os the matrices and all of them are correct and All tests passed.
Can someone help me?
{moderator edit - solution code removed}
You are hard-coding the dimensions to be 55 and 4096. What if the grader uses a test case with a different size?
The point is that we should always strive to write code that is “general”, meaning that it works for inputs of any possible size and shape. Unless they specifically tell you to hard-code dimensions, it is always a mistake to do that.
Note that it is easy to write this code without mentioning any of the dimensions. Instead of using the np.repeat
function to duplicate the mean vector, just use numpy “broadcasting”. You can directly subtract the mean vector from the original matrix and it works fine.
{moderator edit - solution code removed}
Hi
@paulinpaloalto, I agree with you. I have changed my code to become more generic than before, but it still grading zero. Please, see the two attached imagens.
By the way, I have checked all matrix shapes and they are all correct.
Are you sure you hit “Save” before you did the “Submit”? One possibility is that the grader is seeing an older version of your code. I don’t see 4096 in your current code anywhere.
1 Like
I hadn’t saved the file!!!
Thanks, now I have 100%!
2 Likes