megengine.random.RNG.normal

RNG.normal(mean=0, std=1, size=None)[源代码]

Random variable with Gaussian distribution \(N(\mu, \sigma)\).

参数
  • mean (float) – the mean or expectation of the distribution. Default: 0

  • std (float) – the standard deviation of the distribution (variance = \(\sigma ^ 2\)). Default: 1

  • size (Optional[Iterable[int]]) – the size of output tensor. Default: None

返回

the output tensor.

实际案例

import megengine as mge
import megengine.random as rand

x = rand.normal(mean=0, std=1, size=(2, 2))
print(x.numpy())

Outputs:

[[-1.4010863  -0.9874344 ]
 [ 0.56373274  0.79656655]]