mindspore.mint.normal
- mindspore.mint.normal(mean, std, *, generator=None) Tensor [source]
Generates random numbers according to the standard Normal (or Gaussian) random number distribution.
- Parameters
mean (Union[float, Tensor]) – Mean value of each element, the shape of the mean tensor should be the same as that of the std tensor.
std (Union[float, Tensor]) – 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.
- Keyword Arguments
generator (generator, optional) – MindSpore generator. Default:
None
.- Returns
Outputs a tensor with the same shape as mean.
- 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,)
Similar to the function above, but the standard deviations are shared among all drawn elements.
- Parameters
- Returns
Outputs a tensor with the same shape as mean.
- 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) >>> output = mint.normal(mean, 1.0) >>> print(output.shape) (3,)
Similar to the function above, but the means and standard deviations are shared among all drawn elements. The result tensor has size given by size.
- Parameters
- Returns
Outputs a tensor. The shape is specified as size.
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import mint >>> from mindspore import Tensor >>> output = mint.normal(1.0, 2.0, (2, 4)) >>> print(output.shape) (2, 4)