mindspore.ops.random_gamma
- mindspore.ops.random_gamma(shape, alpha, seed=None)[源代码]
根据伽马分布生成随机数。
- 参数:
shape (Tensor) - 指定生成随机数的shape。
alpha (Tensor) -
分布的参数。必须是非负数。seed (int, 可选) - 随机种子,必须为非负数。默认
None
。
- 返回:
Tensor。形状为 mindspore.ops.concat([shape, alpha.shape], axis=0) 。数据类型和alpha一致。
- 支持平台:
CPU
样例:
>>> 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