Hi, in the screenshot below from the graded lab on Linear Regression for Course 1 Week 2,
i can’t solve that error
Your code for compute_cost() does not calculate the cost correctly when tested with weight values that are not zero.
i got the same problem what can i do
Hi @kaki178925,
Please ensure that the implementation of the compute_cost function is correct. You may also refer to the hints provided in the lab notebook for guidance.
Best,
Mujassim
hi @Mujassim_Jamal,
this is my code I am not sure there is a mistake in it
{moderator edit: code removed - posting your code is not allowed}
@kaki178925, Please refrain from posting code in the forums as it is against community guidelines.
It should be total_cost=cost/(2*m)
because the divisor must be computed first. Parenthesis is used to indicate the order of operations that should be performed .
Best,
Mujassim
As @Mujassim_Jamal said, parenthesis are extremely important. What you wrote originally does “divide by 2 then multiply by m”.
I edited the post to remove the code. It’s OK to post your error messages or the assert stack - but do not post your code. Thanks!