W3_A1_Ex-5_Compute cost_Assertion error

cost = 0.6926858869721941

AssertionError Traceback (most recent call last)
in
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

Getting the first cost value correctly, but the next one wrong. Why? The same logic is applied to every data point in the function.

Hello @vazenarayan,

One test can’t speak everything about your function. I suggest you to check out this post for some great suggestions from our Super Mentor Paul :wink:

Raymond

Hi @vazenarayan ,

It looks like there is problem with the calculation, please make sure your code follows the implementation instruction and the formula:

𝐽=−1/𝑚\sum_{i=0}^m ( 𝑦(𝑖)log(𝑎^{[2](𝑖)})+(1−𝑦(𝑖))log(1−𝑎^{[2](𝑖)}))

1 Like