Week 2 Excercise 5 Propagate

I am getting the following error :

AssertionError: Wrong values for grads[‘dw’]. [[-0.00154399]
[-0.00492761]] != [[0.99845601]
[2.39507239]]

However, I have wrote my code following the formula

{moderator edit - solution code removed}

I am not able to figure out the source of error, Any suggestions will be helpful.

you should use np.multiply instead of np.dot in your cost function. it’s a simple * not a dot product here

You have two choices: np.dot with the appropriate transposes or np.multiply followed by np.sum. The code shown will work fine, but the np.sum there is unnecessary.

The real problem must lie someplace else. My guess is it’s a problem with either the sigmoid function or perhaps either the notebook and/or the public_tests.py file is out of date. I modified my code to show the values of Z and A. Here’s what I get for that test case with code that passes the grader:

m = 3
Z = [[ 8.5  0.5 -5.9]]
A = [[0.99979657 0.62245933 0.00273196]]
dw = [[ 0.25071532]
 [-0.06604096]]
db = -0.1250040450043965
cost = 0.15900537707692405
m = 4
Z = [[ 6.5  8.5 -1.7  8. ]]
A = [[0.99849882 0.99979657 0.15446527 0.99966465]]
All tests passed!
1 Like