cost= 1/m *(np.dot(np.log(AL),Y.T)- np.dot(np.log(1-AL),(1-Y).T))

Cost: 0.060773852264651575

Error: Wrong output

**Expected Output** :

**cost** 0.2797765635793422

cost= 1/m *(np.dot(np.log(AL),Y.T)- np.dot(np.log(1-AL),(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

```
cost=-(1/m)*(np.dot(Y.T,np.log(AL))+np.dot((1-Y).T,np.log(1-AL)))
```

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

[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)

in

4 print("Cost: " + str(t_cost))

5

----> 6 compute_cost_test(compute_cost)

~/work/release/W4A1/public_tests.py in compute_cost_test(target)

266 ]

267

β 268 single_test(test_cases, target)

269

270 def linear_backward_test(target):

~/work/release/W4A1/test_utils.py 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(target.**name**))

122

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:

β1πβπ=1π(π¦(π)log(ππΏ)+(1βπ¦(π))log(1βππΏ))

I think you will get it right then. Thanks.

I didnβt realize/ understand that the sequence of arguments going into np.dot 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.