W3 | Planar Data Classification | Backprop wrong dW1

Hello,

I get a very small variation from the expected output, namely:
dW1[2,1], dW1[2,2] and db1[2,1]

// Full error message

AssertionError Traceback (most recent call last)
in
7 print ("db2 = "+ str(grads[“db2”]))
8
----> 9 backward_propagation_test(backward_propagation)

~/work/release/W3A1/public_tests.py in backward_propagation_test(target)
187 assert output[“db2”].shape == expected_output[“db2”].shape, f"Wrong shape for db2."
188
→ 189 assert np.allclose(output[“dW1”], expected_output[“dW1”]), “Wrong values for dW1”
190 assert np.allclose(output[“db1”], expected_output[“db1”]), “Wrong values for db1”
191 assert np.allclose(output[“dW2”], expected_output[“dW2”]), “Wrong values for dW2”

AssertionError: Wrong values for dW1

//My output
dW1 = [[ 0.00301023 -0.00747267]
[ 0.00257967 -0.00641287]
[-0.00156892 0.003893 ]
[-0.00652037 0.01618243]]
db1 = [[ 0.00176201]
[ 0.00150994]
[-0.00091736]
[-0.00381422]]
dW2 = [[ 0.00078841 0.01765429 -0.00084166 -0.01022527]]
db2 = [[-0.16655712]]

//Expected

dW1 = [[ 0.00301023 -0.00747267]
 [ 0.00257968 -0.00641288]
 [-0.00156892  0.003893  ]
 [-0.00652037  0.01618243]]
db1 = [[ 0.00176201]
 [ 0.00150995]
 [-0.00091736]
 [-0.00381422]]
dW2 = [[ 0.00078841  0.01765429 -0.00084166 -0.01022527]]
db2 = [[-0.16655712]]

{Moderator’s Edit: Solution Code Removed}

Thanks!

Hey @Matthew_Brown,
Welcome to the community. Please check the expression of dZ1 carefully. When you are calculating dZ1, we are considering the expression dZ1 = da1 * \frac{\partial{a1}}{\partial{Z1}} where \frac{\partial{a1}}{\partial{Z1}} is supposed to be (1 - np.power(A1, 2)) as pointed out in the tips. Let me know if this helps.

P.S. - Posting code publicly is strictly against the community guidelines. Please refrain from doing so in the future. If a mentor needs to take a look at your code, (s)he will ask you to DM it.

Cheers,
Elemento