mindspore.ops.StandardLaplace
- class mindspore.ops.StandardLaplace(seed=0, seed2=0)[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|)\]Note
Random seed: a set of regular random numbers can be obtained through some complex mathematical algorithms, and the random seed is the initial value of this random number. If the random seed is the same in two separate calls, the random number generated will not change.
Global random seed and operator-level random seed are not set or both set to 0: behavior is completely random.
Global random seed is set, but operator-level random seed is not set: A global random seed will splice with 0 to generate random number.
Global random seed is not set, operator-level random seed is set: 0 splices with the operator-level random seed to generate random number.
Both Global random and operator-level random seed are set: the global random seed will splice with the operator-level random seed to generate random number.
- Parameters
seed (int, optional) – The operator-level random seed, used to generate random numbers, must be non-negative. Default:
0
.seed2 (int, optional) – The global random seed, which combines with the operator-level random seed to determine the final generated random number, must be non-negative. Default:
0
.
- Inputs:
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.
- Outputs:
Tensor. The shape that the input ‘shape’ denotes. The dtype is float32.
- Raises
TypeError – If seed or seed2 is not an int.
TypeError – If shape is neither a tuple nor a Tensor.
ValueError – If seed or seed2 is not a non-negative int.
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, 16) >>> stdlaplace = ops.StandardLaplace(seed=2) >>> output = stdlaplace(shape) >>> result = output.shape >>> print(result) (4, 16)