Np.random.rand() vs np.random.randn()

Hi @Jaskeerat, the main difference between both functions is the distribution of the generated random numbers:
numpy.random.rand() produces numbers in a uniform distribution

and numpy.random.randn() produces numbers in a normal distribution

When used for weight initialization, randn() helps most the weights to Avoid being close to the extremes.
An intuitive way to see it is, for example, if you take the sigmoid() function. You’ll remember that the slope near 0 or near 1 is extremely small, so the weight near those extremes will converge much more slowly to the solution.
Do you refer to the Regularization exercise? the Gradient checking exercise does not require using a random function.
If you refer to the Regularization exercise, there the rand() function is being used to create the Dropout matrix, and not for weight initialization (the first time I did the exercise, I also erroneusly used randn() :wink:)