Hi I’m not sure where my code is wrong. I’m using the same code to initialize W1, and it’s correct for W1, but not W2. The shape is also correct I think. But it’s not giving the correct W2 output using the random function. I wonder if there is a bug.

i got same failure result as yours. then i found i used “np.random.rand()” instead of “np.random.randn()” for W2. do you know why this letter “n” can cause this difference?

**Use this random initialization for the weight matrices: np.random.randn(shape)*0.01 with the correct shape

So, we probably are using the same formula for W1 and W2. To answer your question, ‘n’ designates the number of layers in the hidden layer and the output layer.

Same error as I had:). numpy.random.randn samples numbers from a standard normal distribution it seems. random.rand() samples from a uniform distribution between 0 and 1, so the numbers generated would be different.