mindspore.ops.laplace

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

Generates random numbers according to the Laplace random number distribution.

Support broadcasting.

\[\text{f}(x;μ,λ) = \frac{1}{2λ}\exp(-\frac{|x-μ|}{λ}),\]

Warning

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

Parameters
  • shape (tuple) – The shape specified.

  • mean (Tensor) – The mean of distribution.

  • lambda_param (Tensor) – Control the variance of distribution. The variance of Laplace distribution is equal to twice the square of lambda_param .

  • seed (int, optional) – Random seed. Default None represents 0.

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> shape = (2, 3)
>>> mean = mindspore.tensor(1.0, mindspore.float32)
>>> lambda_param = mindspore.tensor(1.0, mindspore.float32)
>>> output = mindspore.ops.laplace(shape, mean, lambda_param, seed=5)
>>> print(output.shape)
(2, 3)