代码拉取完成,页面将自动刷新
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]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。