mindspore.mint.normal

mindspore.mint.normal(mean=0.0, std=1.0, size=None, generator=None)[source]

Generates random numbers according to the standard Normal (or Gaussian) random number distribution.

Parameters
  • mean (Union[float, Tensor], optional) – Mean value of each element, the shape of the 'mean' tensor should be the same as that of the 'std' tensor. Default: 0.0.

  • std (Union[float, Tensor], optional) – Standard deviation for each element, the shape of the 'std' tensor should be the same as that of the 'mean' tensor. The value of std should be greater than or equal to 0. Default: 1.0.

  • size (tuple, optional) – output size, where 'mean' and 'std' are constants. Default: None.

  • generator (generator, optional) – MindSpore generator. Default: None.

Returns

Outputs a tensor with the same shape as 'mean', or when 'mean' and 'std' are constants and shape is specified as 'size'.

Raises

TypeError – If mean or std is not Union[float, Tensor].

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import mint
>>> from mindspore import Tensor
>>> mean = Tensor(np.array([1.0, 2.0, 3.0]), mindspore.float32)
>>> std = Tensor(np.array([1.0, 2.0, 3.0]), mindspore.float32)
>>> output = mint.normal(mean, std)
>>> print(output.shape)
(3,)