mindspore2022/docs/api/api_python/ops/mindspore.ops.uniform.rst

28 lines
1.6 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.uniform
=======================
.. py:function:: mindspore.ops.uniform(shape, minval, maxval, seed=None, dtype=mstype.float32)
生成服从均匀分布的随机数。
.. note::
广播后任意位置上Tensor的最小值都必须小于最大值。
**参数:**
- **shape** (tuple) - 指定输出shape任意维度的Tensor。 其 :math:`(N,*)` 的长度应小于8。
- **minval** (Tensor) - 指定生成随机值的最小值其数据类型为int32或float32。如果数据类型为int32则只允许输入一个数字。
- **maxval** (Tensor) - 指定生成随机值的最大值其数据类型为int32或float32。如果数据类型为int32则只允许输入一个数字。
- **seed** (int) - 指定随机种子用于随机数生成器生成伪随机数。随机数为非负数。默认值None将被视为0
- **dtype** (mindspore.dtype) - 指定输入的数据类型。如果数据类型为int32则从离散型均匀分布中生成Number如果数据类型是float32则从连续型均匀分布中生成Number。仅支持这两种数据类型。默认值mindspore.float32。
**返回:**
Tensorshape等于输入 `shape``minval``maxval` 广播后的shape。数据类型由输入 `dtype` 决定。
**异常:**
- **TypeError** - `shape` 不是tuple。
- **TypeError** - `minval``maxval` 的数据类型既不是int32也不是float32并且 `minval` 的数据类型与 `maxval` 的不同。
- **TypeError** - `seed` 不是int。
- **TypeError** - `dtype` 既不是int32也不是float32。