Course 1 week 3 exercise 3 wrong values of w1 and w2

I’m having problem with values of W1 and W2 where the output and error is as follow:

W1 = [[0.00435995 0.00025926]
[0.00549662 0.00435322]
[0.00420368 0.00330335]
[0.00204649 0.00619271]]
b1 = [[0.]
[0.]
[0.]
[0.]]
W2 = [[0.00299655 0.00266827 0.00621134 0.00529142]]
b2 = [[0.]]

AssertionError Traceback (most recent call last)
in
8 print("b2 = " + str(parameters[“b2”]))
9
—> 10 initialize_parameters_test(initialize_parameters)

~/work/release/W3A1/public_tests.py in initialize_parameters_test(target)
57 assert parameters[“b2”].shape == expected_output[“b2”].shape, f"Wrong shape for b2."
58
—> 59 assert np.allclose(parameters[“W1”], expected_output[“W1”]), “Wrong values for W1”
60 assert np.allclose(parameters[“b1”], expected_output[“b1”]), “Wrong values for b1”
61 assert np.allclose(parameters[“W2”], expected_output[“W2”]), “Wrong values for W2”

AssertionError: Wrong values for W1

initializing W1 as np.random.rand(n_h, n_x)*0.01

Hi @Asad_Ullah_Wallana,

If you look closely at the instructions of the exercise, you’ll notice something subtle. You are using the rand function, but you are supposed to use the randn function.

Hope this helps,
Mubsi

I’m really silly. Thanks it solved my problem :smile:

Yes, the clue was that all your values are positive, but the expected values are both positive and negative. So how could that happen?

I faxed with same issue, and watched that there is positive and negative values, tried -0.5 to make RND around 0, but it is still not correct.
as @Mubsi mentioned there is proposed different random method randn with “normal” (Gaussian) distribution of mean 0 and variance 1

Hello Promoinytskyi,

Welcome to the community and thank you for your question.

Please show us the values, you are receiving as the expected output.

They essentially write out the code for you in the instructions. You just need to fill in the appropriate dimensions.