Propagate function give assertion error

Help me am stuck
I have written my code which I believe is correct but I keep getting the AssertionError: Wrong values for grads
I have correctly transposed the logA and log(1-A)
but my values are different from the expected outputs
week-2

Yes, there must be something incorrect in your code. Notice that the failed assertion is about the dw values not agreeing with the expected results and dw does not have anything to do with the actual cost values, right? Please check the math formulas given in the text for dw and db and compare carefully to the code you have written.

But now that I look more carefully at the print out from before the assertion, your cost value is also incorrect. Maybe it’s time to go back to first principles and print all the intermediate values, including A which does feed into all the rest of the results. I added some print statements to my code there and here’s what I see when I run that test cell:

A = [[0.99979657 0.62245933 0.00273196]]
type(db) = <class 'numpy.float64'>
type(dw) = <class 'numpy.ndarray'>
dw.shape = (2, 1)
dw = [[ 0.25071532]
 [-0.06604096]]
db = -0.1250040450043965
cost = 0.15900537707692405
A = [[0.99849882 0.99979657 0.15446527 0.99966465]]
type(db) = <class 'numpy.float64'>
type(dw) = <class 'numpy.ndarray'>
dw.shape = (3, 1)
dw = [[-0.03909333]
 [ 0.12501464]
 [-0.99960809]]
db = 0.288106326429569
All tests passed!

Thanks, i had it wrong from the very first step of coding the A variable.

1 Like

Glad to hear that the information was useful in finding the error. Onward! :nerd_face: