tags: np.random.rand np.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
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()。
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 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...
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 Both can initialize a random Numpy array of specified dimensions. Different points are: Numpy.random.random must pass into a tuple to describe the...
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...
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...
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 ....
| 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: contact: Both support @param annotations, specify parameter names, get parameter values. Recommended this way Generally do parameter passing, will us...
for...in 1. Traversing the enumerable properties of an objectName (enumerable: true, passedObject.defineProperty(obj, prop, descriptor) modify, judged by obj.propertyI...