C1_W2_Linear_Regression - Expected output correct but grade 0/100

Hello,

I have an issue with the week 2 practice lab: Linear regression
In UNQ_C1 I wrote the code to compute the cost function

The cost as initial computed is 75.203 which is correct but when executing compute_cost_test(compute_cost) I have an error, see below :

[Image removed as containing code]

I cannot understand the error since compute_cost_test is a black box, but since my cost function returns the expected value for the cost at initial when input with x_train, y_train, initial_w, initial_b, I would expect it to be correct

I have the same error with # UNQ_C2, the output is as expected for the computation of gradient descent with the input of x_train, y_train, initial_w, initial_b, but compute_gradient_test(compute_gradient) returns an error

Therefore my grade is 0/100 but I cannot understant why

Could you please help me?

In case this is needed please see below what I wrote for UNQ_C1, please moderators remove it if it should not be posted here :

[Image removed as containing code]

Thanks a lot!

EDIT : Below the error I get when submitting :
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.

Hi @Abel_THOMAS, Welcome to the community!

Please note you are not allowed to post code in the forums!

Coming back to the problem, in your function compute_cost, you have to use x and y arguments and not the actual x_train and y_train variables. Please compute the linear part first then take the difference as given in the formula provided in lab.

Best Regards,
Mujassim

Hi Mujassim,

Thanks a lot for your prompt reply !
Indeed big error from me, all is fine now :slight_smile:
I removed the images with code from my post

Best Regards,

Abel