# C2_W3 - Exercise 5: Issue with compute cost function. Getting wrong output

I’ve been stuck on this for a while. I’ve tried np.dot and np.multiply:

{moderator edit: code removed}

As far as I know, both shapes being 1, 2000 is correct, logloss has a shape of 1, 2000 and that seems to be correct, I am not sure order matters in np.multiply, I average out the logloss by m, and I retain the negative sign.

My cost is .879 and my expected cost is 0.69

Are you certain you have the equation correct? I think you may be missing a subtraction or minus sign.

Hey!

I think you’re referring to the original equation being more like:

{moderator edit: code removed}

If I do that, the answer doesn’t change. I’m factoring out the negative and putting it in front of np.sum.

``````    ### START CODE HERE ### (~ 2 lines of code)
{moderator edit: code removed}
### END CODE HERE ###
``````

assert(isinstance(cost, float))

``````return cost
``````

print("cost = " + str(compute_cost(A2, Y)))
A2 shape: (1, 2000)
Y.shape: (1, 2000)
logloss: (1, 2000)
cost = 0.7019079882932774

This code is also wrong, unless you think I am still using the - sign incorrectly? I feel like I am missing something silly

The instructions say to implement it like this:

Try this exactly.

Note that the first ‘minus’ is outside the first np.multiply().

Also, the cost value is going to depend on the values of Y and A2. Be sure that every time you modify the code in any cell, that you go back and re-run any cells that modify Y or A2.

{moderator edit: code removed}

The cost here is still slightly off, and failing a test. With this, the output is .7019

##### Expected Output

cost = 0.6931477703826823