2.5K Star 8.4K Fork 4.7K

GVPMindSpore/mindspore

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mindspore.ops.func_rand.rst 994 Bytes
一键复制 编辑 原始数据 按行查看 历史
wind-zyx 提交于 2023-04-21 16:49 . ops update value format 0421

mindspore.ops.rand

.. py:function:: mindspore.ops.rand(*size, dtype=None, seed=None)

    返回一个Tensor,shape和dtype由输入决定,其元素为服从均匀分布的 :math:`[0, 1)` 区间的数字。

    参数:
        - **size** (Union[int, tuple(int), list(int)]) - 输出的Tensor的shape,例如,:math:`(2, 3)` or :math:`2`。

    关键字参数:
        - **dtype** (:class:`mindspore.dtype`,可选) - 指定的输出Tensor的dtype,必须是float类型。如果是None,`mindspore.float32` 会被使用。默认值: ``None`` 。
        - **seed** (int,可选) - 随机种子,必须大于或等于0。默认值: ``None`` ,值将取 ``0`` 。

    返回:
        Tensor,shape和dtype由输入决定其元素为服从均匀分布的 :math:`[0, 1)` 区间的数字。

    异常:
        - **TypeError** - 如果 `seed` 不是非负整数。
        - **ValueError** - 如果 `dtype` 不是一个 `mstype.float_type` 类型。
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mindspore/mindspore.git
git@gitee.com:mindspore/mindspore.git
mindspore
mindspore
mindspore
r2.3.q1

搜索帮助