Error in grading of a week 4 assignment for linear algebra for machine learning and data science course on Coursera

image

That most likely means that you hard-coded the dimensions of the inputs in your implementation of center_data to match those of that one test case. That works in the notebook, but fails when the grader uses a test case with different dimensions. There is no need to hard-code anything there, meaning that you need to write the code in a way that does not make any fixed assumptions about the size of the inputs. The number 55 should appear nowhere in your code.

2 Likes

Thank you, sir! That was straight to the point solution. I have called the shape array of the input instead of hardcoding it, and it’s fixed like that.

1 Like

Nice work! The lesson here is that we always strive to write code that is “general” in the sense that it works with inputs of any dimensions. It’s always a mistake to hard-code assumptions unless you literally have no choice and they specifically tell you to do that.

1 Like