Course 1 - Week 3 - Programming Assignment

Hi! For the life of mine, I have no idea why I am getting this error in the def initialize_parameters. Error below.

The line that seems failing is the simplest one:

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

There is no way to get that wrong, and still the resulting values are rejected by the test.

I have done a ‘reload’ of the .py files already with the most current ones, so I assume that I am running the latest version of the assignment.

Any clue?

Thank you very much!

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

Expected output

W1 = [[-0.00416758 -0.00056267]
[-0.02136196 0.01640271]
[-0.01793436 -0.00841747]
[ 0.00502881 -0.01245288]]
b1 = [[0.]
[0.]
[0.]
[0.]]
W2 = [[-0.01057952 -0.00909008 0.00551454 0.02292208]]
b2 = [[0.]]
All tests passed!

Hi @Juan_Olano,

You are using the rand function. If you pay close attention to the instructions, you’ll see that it mentions to use the randn, this is a subtle, but a big, and might I add, an annoying, difference :joy:

Best,
Mubsi

@Mubsi ah!!! Oh boy. Thanks a lot!