I have all the functions working prior to the cost function.
I am using the equation provided. Test 1 passes with incorrect output.
I am using np.multiply to get the logprobs and then multiply that by -1/m * np.sum(logprobs)
The other tests fail with the following error message:
Costs are always positive by definition, so something is clearly wrong. Maybe your logprobs value has already been multiplied by -1? Also note that the logprobs computation they show you in the notebook is not the whole story: it’s just part of one term of the total cost formula, right? Compare your code to the math formula for the cost.
Please note that the compute_cost function here is completely independent of forward propagation: it just takes A2 as an input. So the correctness of your cost calculation is independent of the correctness of the rest of your code. The test case just supplies a value of A2, which they generated by some other means.
Also note that some of the functions here have multiple test cases and the first test case frequently just checks the data type of the output, not the value. So the fact that the first test passed just says that at least your output value is a numpy floating point scalar value or whatever the test case is checking for. You can examine the test cases by clicking “File → Open” and then reading the file public_tests.py.