mindspore.ops.random_gamma

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

Generate random numbers from the Gamma distribution(s).

Parameters
  • shape (Tensor) – The shape of random tensor to be generated.

  • alpha (Tensor) – The \(\alpha\) distribution parameter.

  • seed (int, optional) – Random seed, must be non-negative. Default None .

Returns

Tensor, the shape is mindspore.ops.concat([shape, rate.shape], axis=0). The data type is the same as alpha.

Supported Platforms:

CPU

Examples

>>> import mindspore
>>> shape = mindspore.tensor([7, 5], mindspore.int32)
>>> alpha = mindspore.tensor([0.5, 1.5], mindspore.float32)
>>> output = mindspore.ops.random_gamma(shape, alpha, seed=5)
>>> print(output.shape, output.dtype)
(7, 5, 2) Float32