Week 3 Planar Data Classification program

I am not getting the correct cost in exercise 5. Here is my code:

{mentor edit: code removed}

The error I get is the following:

cost = 0.6926858869721941

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-37-9523b300d7a7> in <module>
      3 print("cost = " + str(compute_cost(A2, t_Y)))
      4 
----> 5 compute_cost_test(compute_cost)

~/work/release/W3A1/public_tests.py in compute_cost_test(target)
    131 
    132     assert type(output_1) == float, "Wrong type. Float expected"
--> 133     assert np.isclose(output_1, expected_output_1), f"Wrong value. Expected: {expected_output_1} got: {output_1}"
    134 
    135     assert type(output_2) == float, "Wrong type. Float expected"

AssertionError: Wrong value. Expected: 0.5447066599017815 got: 1.0493608309109266


Expected output

cost = 0.6930587610394646
All tests passed!

HI @rvgeiger ,

You have only implemented one part of the cost formula, please check the formula (13) for calculating J.

1 Like

Right! The sample code that they gave you is not the complete solution. They even mention that in the instructions, although perhaps they were a bit too subtle about it. :nerd_face:

Compare that code to the math formula for the cost and ask yourself:

  1. What happened to the factor of \frac {1}{m}?
  2. What happened to the y = 0 term?

Thank you. That was silly of me!

Thank you. Not paying attention!

Please do not share your code on the forum. That’s not allowed by the Code of Conduct.