I need help finding what I am doing wrong in calculating cost for the propagate function in week 2 programming exercise. I have confirmed that the values for my A matrix are correct (from other threads on this topic). I am using np.dot and have also validated the calculation in Excel and gettin the same values (i.e. -2.14 for the first test with m=3 and -0.966 for the second test case with m=4).

Can’t figure out my error and need help. see the output from my notebook below:

##
m=3

Y=[[1 1 0]]

A=[[0.99979657 0.62245933 0.00273196]]

dw = [[ 0.25071532]

[-0.06604096]]

db = -0.1250040450043965

cost = -2.1428184225087668

m=4

Y=[[1 1 0 0]]

A=[[0.99849882 0.99979657 0.15446527 0.99966465]]

AssertionError Traceback (most recent call last)

in

14 print ("cost = " + str(cost))

15

—> 16 propagate_test(propagate)

~/work/release/W2A2/public_tests.py in propagate_test(target)

51 assert np.allclose(grads[‘dw’], expected_dw), f"Wrong values for grads[‘dw’]. {grads[‘dw’]} != {expected_dw}"

52 assert np.allclose(grads[‘db’], expected_db), f"Wrong values for grads[‘db’]. {grads[‘db’]} != {expected_db}"

—> 53 assert np.allclose(cost, expected_cost), f"Wrong values for cost. {cost} != {expected_cost}"

54 print(‘\033[92mAll tests passed!’)

55

AssertionError: Wrong values for cost. -0.9666039194818195 != 2.0424567983978403