mindspore.ops.gamma
- mindspore.ops.gamma(shape, alpha, beta, seed=None)[source]
Generates random numbers according to the Gamma random number distribution.
- Parameters
shape (tuple) – The shape of random tensor to be generated.
alpha (Tensor) – The alpha α distribution parameter. It should be greater than 0 with float32 data type.
beta (Tensor) – The beta β distribution parameter. It should be greater than 0 with float32 data type.
seed (int) – Seed is used as entropy source for the random number engines to generate pseudo-random numbers, must be non-negative. Default: None, which will be treated as 0.
- Returns
Tensor. The shape should be equal to the broadcasted shape between the input “shape” and shapes of alpha and beta. The dtype is float32.
- Raises
- Supported Platforms:
Ascend
Examples
>>> shape = (3, 1, 2) >>> alpha = Tensor(np.array([[3, 4], [5, 6]]), mstype.float32) >>> beta = Tensor(np.array([1.0]), mstype.float32) >>> output = C.gamma(shape, alpha, beta, seed=5) >>> result = output.shape >>> print(result) (3, 2, 2)