AssertionError: Wrong values for A2 : [Planar_data_classification_with_one_hidden_layer]

HI,

I am getting below error in forward_propagation()

A2 = [[0.49993903 0.50002176 0.50002679]]

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 tried to restart the kernel and also tried in a new notebook . But still stuck with this issue.

Can someone suggest the way to resolve it.

1 Like

Hello @Mona_S,

Kindly select the correct specialisation, course and week specification for better response from your respective mentors.

Your A2 values is throwing error because of wrong value of A1 and Z1. so check if the shape assertion done is correctly or not.

Regards
DP

1 Like

This looks like it’s about the Planar Data assignment in DLS Course 1 Week 3, so I used the little “edit pencil” on the title to move it for you. If I jumped to the wrong conclusion here, please let me know or just fix it by doing your own edit to the category.

The value you show for A2 is not correct. Here’s what I see with correct code:

A2 = [[0.21292656 0.21274673 0.21295976]]
All tests passed!

But it turns out that I have seen an error from another student recently that also produces exactly the same wrong answer that you show. Note that we do not want to call the initialization routine within the body of forward_propagation, because that would defeat the purpose here. E.g. it would mean that every time we call this, we get the same answer, because we start from the initialized values of the parameters.

Of course there may be other ways to get that incorrect answer, so if that’s not it, then please compare your code to the steps described in the instructions.

1 Like