2.4K Star 8.2K Fork 4.4K

GVPMindSpore / mindspore

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
randperm_v2_doc.yaml 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
chenfei_mindspore 提交于 2024-02-26 16:24 . move doc.yaml to doc dir
randperm_v2:
description: |
Generates random permutation of integers from 0 to n-1.
Returns the tensor with the determined shape inferred by n, the random numbers in it drawn from the data range
that a given type can represent.
.. warning::
This is an experimental API that is subject to change or deletion.
Args:
n (Union[Tensor, int]): The input n Tensor with shape: () or (1,) and with data type of int64.
The value of `n` must be greater than zero.
seed (int, optional): Random seed. Default: ``0`` . When seed is -1(only negative value), offset is 0,
it's determined by time.
offset (int, optional): Offset to generate random numbers. Priority is higher than random seed.
Default: ``0`` . It must be non-negative.
dtype (mindspore.dtype, optional): The type of output.
Its value must be one of the following types: int32, int16, int8,
uint8, int64, float64, float32, float16. Default: mstype.int64.
Returns:
Tensor. Its shape is specified by the required args `n`. Its type is specified by `dtype`.
Otherwise is default.
Raises:
TypeError: If `dtype` is not allowed.
ValueError: If `n` is a negative or 0 element.
ValueError: If `seed` is a negative element.
ValueError: If `n` is larger than the maximal data of the set dtype.
Supported Platforms:
``CPU``
Examples:
>>> from mindspore import ops
>>> from mindspore import dtype as mstype
>>> n = 4
>>> seed = 0
>>> offset = 0
>>> output = ops.randperm(n, seed, offset, dtype=mstype.int64)
>>> print(output)
[0 2 1 3]
Python
1
https://gitee.com/mindspore/mindspore.git
git@gitee.com:mindspore/mindspore.git
mindspore
mindspore
mindspore
master

搜索帮助