mindspore.ops.RandomShuffle
- class mindspore.ops.RandomShuffle(seed=0, seed2=0)[source]
Randomly shuffles a Tensor along its first dimension.
Note
Random seed: a set of regular random numbers can be obtained through some complex mathematical algorithms, and the random seed determines the initial value of this random number. If the random seed is the same in two separate calls, the random number generated will not change.
Using the Philox algorithm to scramble seed and seed2 to obtain random seed so that the user doesn't need to worry about which seed is more important.
- Parameters
seed (int, optional) – The operator-level random seed, used to generate random numbers, must be non-negative. Default:
0
.seed2 (int, optional) – The global random seed, which combines with the operator-level random seed to determine the final generated random number, 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
>>> import numpy as np >>> from mindspore import Tensor, ops >>> from mindspore import dtype as mstype >>> x = Tensor(np.array([1, 2, 3, 4]), mstype.float32) >>> shuffle = ops.RandomShuffle(seed=1, seed2=1) >>> output = shuffle(x) >>> print(output.shape) (4,)