{moderator edit - solution code removed}
w = np.array([[1.], [2]])
b = 1.5
X = np.array([[1., -2., -1.], [3., 0.5, -3.2]])
Y = np.array([[1, 1, 0]])
grads, cost = propagate(w, b, X, Y)
assert type(grads[“dw”]) == np.ndarray
assert grads[“dw”].shape == (2, 1)
assert type(grads[“db”]) == np.float64
print ("dw = " + str(grads[“dw”]))
print ("db = " + str(grads[“db”]))
print ("cost = " + str(cost))
propagate_test(propagate)
I am getting the below error for cost. I am not understanding what is wrong with the cost.
dw = [[ 0.25071532] [-0.06604096]] db = -0.12500404500439652 cost = [[6.78158907e-05 1.58025661e-01 1.96757857e+00] [6.78158907e-05 1.58025661e-01 1.96757857e+00] [2.83340115e+00 3.24692328e-01 9.11899793e-04]] ---------------------------------------------------------------------------AssertionError Traceback (most recent call last) in 14 print (“cost = “+ str(cost)) 15—> 16propagate_test(propagate)~/work/release/W2A2/public_tests.py in propagate_test(target) 41assert np.allclose(grads[‘dw’], expected_dw),f"Wrong values for grads[‘dw’]. {grads[‘dw’]} != {expected_dw}” 42assert np.allclose(grads[‘db’], expected_db),f"Wrong values for grads[‘db’]. {grads[‘db’]} != {expected_db}”—> 43assert np.allclose(cost, expected_cost),f"Wrong values for cost. {cost} != {expected_cost}" 44 print(’\033[92mAll tests passed!’) 45AssertionError: Wrong values for cost. [[3.75577540e-04 5.08619180e-05 4.66946507e-01 8.38515932e-05] [3.75577540e-04 5.08619180e-05 4.66946507e-01 8.38515932e-05] [1.62537558e+00 2.12505086e+00 4.19465073e-02 2.00008385e+00] [1.62537558e+00 2.12505086e+00 4.19465073e-02 2.00008385e+00]] != 2.0424567983978403