\add random_shuffle docs

This commit is contained in:
fan-jibin 2022-09-27 10:42:38 +08:00
parent 376f7f92dd
commit bc2a361823
5 changed files with 27 additions and 7 deletions

View File

@ -282,6 +282,7 @@ Tensor创建
mindspore.ops.random_poisson
mindspore.ops.random_categorical
mindspore.ops.random_gamma
mindspore.ops.shuffle
mindspore.ops.standard_laplace
mindspore.ops.standard_normal
mindspore.ops.uniform

View File

@ -0,0 +1,16 @@
mindspore.ops.shuffle
=====================
.. py:function:: mindspore.ops.shuffle(x, seed=None)
沿着Tensor第一维随机打乱数据。
参数:
- **x** (Tensor) - 需要随机打乱的Tensor。
- **seed** (int) - 随机数种子,用于生成随机数,必须为非负数。如果 `seed` 为0则替换为随机生成的值。默认值是None, 表示使用0作为随机数种子。
返回:
Tensor与输入相同的shape和类型。
异常:
- **TypeError** - 如果 `seed` 不是None或非负整数。

View File

@ -281,6 +281,7 @@ Randomly Generating Functions
mindspore.ops.random_poisson
mindspore.ops.random_categorical
mindspore.ops.random_gamma
mindspore.ops.shuffle
mindspore.ops.standard_laplace
mindspore.ops.standard_normal
mindspore.ops.uniform

View File

@ -397,16 +397,17 @@ def shuffle(x, seed=None):
Args:
x (Tensor): The Tensor need be shuffled.
seed (int): The operator-level random seed, used to generate random numbers, must be non-negative. Default: 0.
seed (int): Random seed used for random number generation, must be non-negative. If `seed` is 0, which will be
replaced with a randomly generated value. Default: None, which will be treated as 0.
Returns:
Tensor. The shape and type are the same as the input `x`.
Raises:
TypeError: If data type of `seed` or `seed2` is not int.
TypeError: If data type of `seed` is not None or non-negative int.
Supported Platforms:
``CPU`` ``GPU``
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> x = Tensor(np.array([1, 2, 3, 4]), mstype.float32)

View File

@ -905,9 +905,10 @@ class RandomShuffle(Primitive):
Randomly shuffles a Tensor along its first dimension.
Args:
seed (int): The operator-level random seed, used to generate random numbers, must be non-negative. Default: 0.
seed2 (int): The global random seed and it will combile with the operator-level random seed to determine the
final generated random number, must be non-negative. Default: 0.
seed (int): Random seed. If `seed` or `seed2` is set to non-zero, the random number generator will be seeded
by the given seed. Otherwise, it will be seeded randomly. The seed must be non-negative. Default: 0.
seed2 (int): Random seed2, a second seed to avoid seed collision. If `seed` is 0, the `seed2` will be used as
the seed of the random generator. It must be non-negative. Default: 0.
Inputs:
- **x** (Tensor) - The Tensor need be shuffled.
@ -919,7 +920,7 @@ class RandomShuffle(Primitive):
TypeError: If data type of `seed` or `seed2` is not int.
Supported Platforms:
``CPU`` ``GPU``
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> x = Tensor(np.array([1, 2, 3, 4]), mstype.float32)