mindspore.ops.RandomShuffle
- class mindspore.ops.RandomShuffle(seed=0, seed2=0)[source]
Randomly shuffles a Tensor along its first dimension.
- Parameters
seed (int, optional) – 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, optional) – 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.
- Outputs:
Tensor. The shape and type are the same as the input x.
- Raises
TypeError – If data type of seed or seed2 is not int.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> x = Tensor(np.array([1, 2, 3, 4]), mstype.float32) >>> shuffle = ops.RandomShuffle(seed=1, seed2=1) >>> output = shuffle(x) >>> print(output.shape) (4,)