Week 2 practice lab - Linear regression, error on grading

C1_W2_Linear_Regression
for the Week 2 practice lab: Linear regression, I finished my implemention of both functions and submitted for grading, got error message for function compute_cost only, but I tested it I get the expected result as shown in following test code cell. failed with grading got only 50% pass. I did not see any issue with my code.

error message:
Code Cell UNQ_C1: Unexpected error (IndexError(‘index 3 is out of bounds for axis 0 with size 3’)) occurred during function check. We expected function compute_cost to return cost for perfect prediction must be 0. Please check that this function is defined properly.

Much appreciated for support this issue so I can pass the weeks grading.
Best regards, Luke

It seems the grader is not passing all the tests on your UNQ_C1, keep in mind that the grader has a bunch of different tests than those run in the script. Apparently from this error I can think that you are accessing an element beyond a array’s size!

Thanks a lot Gent, Tom helped to find one bug regarding my careless reference 2 variables in the function.

1 Like