mindspore.ops.RandomGamma
- class mindspore.ops.RandomGamma(seed=0, seed2=0)[source]
Produces random positive floating-point values x, distributed according to probability density function:
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 (Tensor) - The shape of random tensor to be generated. It must be constant value.
alpha (Tensor) - α is the shape parameter of RandomGamma distribution, it mainly determines the shape of the graph curve. It must be greater than 0 and have date type float32.
- Outputs:
Tensor. The shape should be equal to the concat shape between the input shape and alpha. The dtype is the same type as alpha.
- Raises
TypeError – If data type of seed or seed2 is not int.
TypeError – If shape or alpha is not a Tensor.
TypeError – If data type of alpha is not float32.
ValueError – If shape is not a constant value.
- Supported Platforms:
CPU
Examples
>>> import numpy as np >>> from mindspore import Tensor, ops >>> from mindspore import dtype as mstype >>> shape = Tensor(np.array([3, 1, 2]), mstype.int32) >>> alpha = Tensor(np.array([[3, 4], [5, 6]]), mstype.float32) >>> gamma = ops.RandomGamma(seed=3) >>> output = gamma(shape, alpha) >>> result = output.shape >>> print(result) (3, 1, 2, 2, 2)