randperm¶
- paddle. randperm ( n, dtype='int64', name=None ) [source]
-
Returns a 1-D Tensor filled with random permutation values from 0 to n-1, with
dtype
.- Parameters
-
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.
- Returns
-
A 1-D Tensor filled with random permutation values from 0 to n-1, with
dtype
. - Return type
-
Tensor
Examples
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