mindspore.ops.standard_laplace

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

Generates random numbers according to the Laplace random number distribution (mean=0, lambda=1). It is defined as:

\[\text{f}(x) = \frac{1}{2}\exp(-|x|)\]
Parameters
  • shape (Union[tuple, Tensor]) – The shape of random tensor to be generated. Only constant value is allowed when the input type is tuple. And the operator supports dynamic shape only when the input type is Tensor.

  • seed (int, optional) – Seed is used as entropy source for Random number engines generating pseudo-random numbers. Default: None , which will be treated as 0.

Returns

Tensor. The shape that the input 'shape' denotes. The dtype is float32.

Raises
  • TypeError – If shape is neither a tuple nor a Tensor.

  • 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

>>> from mindspore import ops
>>> shape = (4, 4)
>>> output = ops.standard_laplace(shape)
>>> result = output.shape
>>> print(result)
(4, 4)