Error code: Case 2: Cost must be 2 but got 0.5
Does anyone know what I am doing wrong?
It seems something goes wrong at case 2…
{moderator edit: code removed}
Error code: Case 2: Cost must be 2 but got 0.5
Does anyone know what I am doing wrong?
It seems something goes wrong at case 2…
{moderator edit: code removed}
I got it, it was the return function that was tabbed two times instead of 1 (returning out of the for loop i think)
I’m glad you fixed the problem.
Please be careful in the future that you do not post your code on the forum. That’s not allowed by the code of conduct for the forum.
I got this same error. Please how do I rectify it?
Sounds like there’s an error in your code.
Check your for loops (what is in the for loop what is out) and make sure your spaces are right for the loops. Good luck!
I’ve tried, sadly I’m still not getting it.
Please how do I go about fixing it?
Share your full error please.
please help, i have the same problem.
Sharing your full error will help us understand your problem…
Here is the error,
AssertionError Traceback (most recent call last)
in
9 # Public tests
10 from public_tests import *
—> 11 compute_cost_test(compute_cost)
~/work/public_tests.py in compute_cost_test(target)
17 initial_b = 1.0
18 cost = target(x, y, initial_w, initial_b)
—> 19 assert cost == 2, f"Case 2: Cost must be 2 but got {cost}"
20
21 # print(“Using X with shape (5, 1)”)
AssertionError: Case 2: Cost must be 2 but got 0.5
It means that your implementation of the compute_cost
function is not correct. Double-check how you are implementing this function. Check hints and more hints below that cell.
Hi @okpe_blessing ,
The error trace is showing that your calculated cost is 0, so how could that happen?
Please check your code against the instructions from the hints. Put a print statement inside the for loop and check what is the calculated cost value for each example.
Okay thanks a lot. Let me try this and update on its proceeds.
Problem rectified, thanks everyone for your help.
Never mind I got it