- paddle. randperm ( n, dtype='int64', name=None )
Returns a 1-D Tensor filled with random permutation values from 0 to n-1, with
n (int) – The upper bound (exclusive), and it should be greater than 0.
dtype (str|np.dtype, optional) – The data type of the output Tensor. Supported data types: int32, int64, float32, float64. Default is int64.
name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.
A 1-D Tensor filled with random permutation values from 0 to n-1, with
- Return type
import paddle out1 = paddle.randperm(5) # [4, 1, 2, 3, 0] # random out2 = paddle.randperm(7, 'int32') # [1, 6, 2, 0, 4, 3, 5] # random