mindspore.ops.standard_normal

View Source On Gitee
mindspore.ops.standard_normal(shape, seed=None)[source]

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

f(x)=12πe(x22)

Warning

The Ascend backend does not support the reproducibility of random numbers, so the seed parameter has no effect.

Parameters
  • shape (Union[tuple, Tensor]) – The shape of returned tensor.

  • seed (int, optional) – Random number Seed. Default None .

Returns

Tensor

Raises
  • ValueError – If shape is a tuple containing non-positive items.

  • ValueError – If shape is a Tensor, and the rank of the Tensor is not equal to 1.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> shape = (4, 4)
>>> output = mindspore.ops.standard_normal(shape, seed=5)
>>> print(f'output shape is {output.shape}')
output shape is (4, 4)
(4, 4)