mindspore/docs/api/api_python/ops/mindspore.ops.Gamma.rst

39 lines
2.2 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.Gamma
===================
.. py:class:: mindspore.ops.Gamma(seed=0, seed2=0)
根据概率密度函数分布生成随机正值浮点数x。函数定义如下
.. math::
\text{P}(x|α,β) = \frac{\exp(-x/β)}{{β^α}\cdot{\Gamma(α)}}\cdot{x^{α-1}}
.. note::
- 随机种子:通过一些复杂的数学算法,可以得到一组有规律的随机数,而随机种子就是这个随机数的初始值。随机种子相同,得到的随机数就不会改变。
- 全局随机种子和算子层随机种子均未设置或均为0时生成完全随机数。
- 全局随机种子已设置但算子层随机种子未设置时将全局随机种子与0进行拼接。
- 全局随机种子未设置但算子层随机种子已设置时将0与算子层随机种子进行拼接。
- 全局随机种子和算子层随机种子均已设置时:将全局随机种子与算子层随机种子进行拼接。
.. warning::
Ascend后端不支持随机数重现功能 `seed``seed2` 参数不起作用。
参数:
- **seed** (int可选) - 算子层的随机种子,用于生成随机数。必须是非负的。默认值: ``0``
- **seed2** (int可选) - 全局的随机种子,和算子层的随机种子共同决定最终生成的随机数。必须是非负的。默认值: ``0``
输入:
- **shape** (tuple) - 待生成的随机Tensor的shape。只支持常量值。
- **alpha** (Tensor) - α为Gamma分布的shape parameter主要决定了曲线的形状。其值必须大于0。数据类型为float32。
- **beta** (Tensor) - β为Gamma分布的inverse scale parameter主要决定了曲线有多陡。其值必须大于0。数据类型为float32。
输出:
Tensor。shape是输入 `shape` `alpha` `beta` 广播后的shape。数据类型为float32。
异常:
- **TypeError** - `seed``seed2` 的数据类型不是int。
- **TypeError** - `alpha``beta` 不是Tensor。
- **TypeError** - `alpha``beta` 的数据类型不是float32。
- **ValueError** - `shape` 不是常量值。