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

35 lines
1.3 KiB
ReStructuredText
Raw 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.UniformInt
========================
.. py:class:: mindspore.ops.UniformInt(seed=0, seed2=0)
根据均匀分布在区间 `[minval, maxval)` 中生成随机数,即根据离散概率函数分布:
.. math::
\text{P}(i|a,b) = \frac{1}{b-a+1},
其中 :math:`a` 为分布区间的最小值 `minval` :math:`b` 为分布区间的最大值 `maxval`
.. note::
`minval` 中的数值在广播后必须严格小于 `maxval`
参数:
- **seed** (int) - 随机种子非负值。默认值0。
- **seed2** (int) - 随机种子2用来防止随机种子冲突非负值。默认值0。
输入:
- **shape** (tuple) - 目标Tensor的shape。只允许常量值。
- **minval** (Tensor) - 分布参数, :math:`a`
决定可能生成的最小值数据类型为int32。需为标量。
- **maxval** (Tensor) - 分布参数, :math:`b`
决定生成随机数的上限数据类型为int32。需为标量。
输出:
Tensor。shape为输入 `shape` 数据类型支持int32。
异常:
- **TypeError** - `seed``seed2` 不是int类型。
- **TypeError** - `shape` 不是Tuple。
- **TypeError** - `minval``maxval` 不是Tensor。
- **ValueError** - `shape` 不是常量值。