Wrong values for A2 in forward_propagation function

it shows the following error message "---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
in
3 print("A2 = " + str(A2))
4
----> 5 forward_propagation_test(forward_propagation)

~/work/release/W3A1/public_tests.py in forward_propagation_test(target)
108 assert output[1][“Z2”].shape == expected_Z2.shape, f"Wrong shape for cache[‘Z2’]."
109
→ 110 assert np.allclose(output[0], expected_A2), “Wrong values for A2”
111 assert np.allclose(output[1][“Z1”], expected_Z1), “Wrong values for cache[‘Z1’]”
112 assert np.allclose(output[1][“A1”], expected_A1), “Wrong values for cache[‘A1’]”

AssertionError: Wrong values for A2"

I actually printed W1, b1, W2, b2 and X to a separate Jupyter Notebook to calculate, the calculation of Z1, A1, Z2 in Jupyter Notebook matched with Coursera assignment, but the calculation of A2 is different. I got Z2 in both as array([[-2.43884496e-04, 8.70207555e-05, 1.07176527e-04]]), if using A2 = sigmoid(Z2), I got A2=array([[0.49993903, 0.50002176, 0.50002679]]), but the test expects to get
A2 = [[0.21292656 0.21274673 0.21295976]], and reports Wrong values for A2.

Please help.

thanks

If this doesn’t help, please click my name and message your notebook as an attachment.

Here’s a post in Balaji’s list that shows the intermediate values for Z1 and A1 and Z2 and the Z2 differs from yours.

One thing to check is to make sure you got the activation function right for layer 1: it’s tanh, right? Not relu or sigmoid.

Why are you overwriting the parameter parameters with a custom

parameters = initialize_parameters(n_x, n_h, n_y) 

inside the function forward_propagation ?

Thanks, I already realized I accidently copied this over inside the function forward_propagation. please delete this post.

I have unlisted the thread.