The difference between numpy.random.rand() and numpy.random.randn()

tags: np.random.rand  np.random.randn

The difference between numpy.random.rand() and numpy.random.randn()

When building a deep network manually, we generally usenumpy.random.randn()To initialize the parameters. Thennumpy.random.randn()withnumpy.random.rand()what differences are there?

import numpy as np
a =  np.random.rand(4, 1)
b = np.random.randn(4, 1)
print(a)
print("\n")
print(b)

import numpy as np
a =  np.random.rand(4, 1)
b = np.random.randn(4, 1)
print(a)
print("\n")
print(b)
​Result:
[[0.98429255]
 [0.25342119]
 [0.26999272]
 [0.24893671]]


[[ 0.07078823]
 [-0.54274356]
 [ 0.29564877]
 [-2.00665922]]

numpy.random.rand()Generated from [ 0 , 1 ) [0,1) There is no negative value between the random numbers.
numpy.random.randn()Producing a random number that follows a normal distribution will result in a negative value.

The parameters in deep learning are likely to have negative values, so we don't use them.numpy.random.rand()

Intelligent Recommendation

Numpy.random.randn() usage

1 numpy.random.rand() 2 numpy.random.randn() 3 numpy.random.randint() 4 Generate floating point numbers between [0, 1) 5 numpy.random.choice() 6 numpy.random.seed()  reference: Above, record my l...

numpy.random.randn () usage

numpy in ravel (), flatten (), squeeze () to convert multidimensional array has a one-dimensional array of function, the difference between: ravel (): if not necessary, no copy of the source data flat...

How to use numpy.random.rand()

Use numpy.random.rand() to generate any random number (0, 1) Generate a single random number Generate random numbers of specified shape --------------------------------------end-----------------------...

Numpy.random.random and numpy.random.rand distinction

Numpy.random.random and numpy.random.rand distinction Both can initialize a random Numpy array of specified dimensions. Different points are: Numpy.random.random must pass into a tuple to describe the...

numpy.random.randn () and rand () usage

In the study and application of python data analysis, often we need to use the random function numpy, due to the random function random function more often confused or can not remember, let's take a s...

More Recommendation

numpy.random.randn usage and explanation

Usage: enter:d0, d1, ..., dn : int, optional return:A (d0, d1, ..., dn)-shaped The size of the floating-point sampling array that follows the standard normal distribution (mea...

Introduction to Numpy.random.randn () and Rand ()

  Np.random.Rand (D0, D1, D2 ..... DN) Returns one or a random sample value from "0 ~ 1" uniform distribution, and the random sample value range is [0, 1). Np.random.randn (D0, D1, D2 ....

The difference between || and the difference between &&&

| and || both represent or, the difference is that when || encounter multiple conditions, judge from left to right. As long as one condition is true, the entire judgment is considered true, and the re...

The difference between #{} and ${}

The difference between #{} and ${} the difference: contact: Both support @param annotations, specify parameter names, get parameter values. Recommended this way Generally do parameter passing, will us...

The difference between for...in and for...of

for...in 1. Traversing the enumerable properties of an objectName         (enumerable: true, passedObject.defineProperty(obj, prop, descriptor) modify, judged by obj.propertyI...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top