Error in exercise 6 compute_cost function of week 4 assignment 1

cost= 1/m *(,Y.T)-,(1-Y).T))
Cost: 0.060773852264651575
Error: Wrong output

Expected Output :

cost 0.2797765635793422

Your formula is incorrect.

ya thanks i figured it out lately

1 Like

I thought my formula above is correct but still getting error. What am I missing?

Cost: [[0.07438118 0.03512017 0.30543024]
[0.07438118 0.03512017 0.30543024]
[0.5364793 0.76752836 0.17027521]]
Error: Wrong output
0 Tests passed
1 Tests failed

AssertionError Traceback (most recent call last)
4 print("Cost: " + str(t_cost))
----> 6 compute_cost_test(compute_cost)

~/work/release/W4A1/ in compute_cost_test(target)
266 ]
β†’ 268 single_test(test_cases, target)
270 def linear_backward_test(target):

~/work/release/W4A1/ in single_test(test_cases, target)
119 print(’\033[92m’, success," Tests passed")
120 print(’\033[91m’, len(test_cases) - success, " Tests failed")
β†’ 121 raise AssertionError(β€œNot all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(
123 def multiple_test(test_cases, target):

AssertionError: Not all tests were passed for compute_cost. Check your equations and avoid using global variables inside the function.

Hi @Kimberly_Chan, check the way you are computing the values as per the given formula:


I think you will get it right then. Thanks.

I didn’t realize/ understand that the sequence of arguments going into actually matters??

Matrix multiplication (dot product style) is well known not to be commutative, so the order matters. Here’s a thread which discusses this as it applies to the cost function.