Test for initialize_parameters() fails in the assignment for Week 3

The unit tests for the initialize_parameters() fails in my assignment for Week 3. Here is what the method generates:

W1 = [[0.00435995 0.00025926]
 [0.00549662 0.00435322]
 [0.00420368 0.00330335]
 [0.00204649 0.00619271]]

W2 = [[0.00299655 0.00266827 0.00621134 0.00529142]]

And here is what the unit test expects:

W1 = [[-0.00416758 -0.00056267]
 [-0.02136196  0.01640271]
 [-0.01793436 -0.00841747]
 [ 0.00502881 -0.01245288]]

W2 = [[-0.01057952 -0.00909008  0.00551454  0.02292208]]

I initialize W1 and W2 with np.random.randn(a,b) * 0.01 as recomended.

The method code includes np.random.seed(2) (I have not changed this code).

I would not bother with this as the parameters/weights are supposed to be random anyway. But I have some more issues later in the assignment so I would like to fix this one first to make sure it has no connection with my other issues. Could someone help me please?

It looks like I have a similar problem with tests for the method predict() as well.

Hi @Alexey. Study your output. Suspiciously, your draws for W1 and W2: 1) do not include any negative values, and 2) if one divides each by 100, all values fall in the unit interval. That a hint! :thinking:

Also, and importantly, you are not allowed to include your work in your posts. It is a violation of the Coursera Honor Code.

2 Likes

Hi @kenb Thank you! I used np.random.rand() instead of np.random.randn(). It was the cause of the problem.

All code that I posted was from the assignment instructions, not from my work.

2 Likes