C1_W2_Linear_Regression --> predictions are correct, but still getting a function incorrect error... what might be wrong?

week #1
graded lab → C1_W2_Linear_Regression

all the outputs of the model are matching expected values (for predictions and other tests).

Yet, still getting these errors. What might be wrong?

“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.
Code Cell UNQ_C2: Unexpected error (IndexError(‘index 3 is out of bounds for axis 0 with size 3’)) occurred during function check. We expected function compute_gradient to return compute_gradient failed expected [2., [0]]. Please check that this function is defined properly.
If you see many functions being marked as incorrect, try to trace back your steps & identify if there is an incorrect function that is being used in other steps.
This dependency may be the cause of the errors.”

Your code only works correctly for the data set and conditions in the notebook. The notebook’s tests are not conclusive - the grader uses different tests.

The first things to check are:

  • does your code use fixed constants for sizes or shapes?
  • does your code use any global variables?
1 Like

figured out i was referring to the variables as x_train[*] and y_train[*] in these calculations vs x[] and y[]. Hence correct calcs but incorrect functions. Fixed it. Thanks for the help!

1 Like