megengine.random.RNG.permutation¶
- RNG.permutation(n, *, dtype='int32')[源代码]¶
Generates a random permutation of integers from \(0\) to \(n - 1\).
- 参数
- 返回
the output tensor.
实际案例
import megengine as mge import megengine.random as rand x = rand.permutation(n=10, dtype="int32") print(x.numpy()) x = rand.permutation(n=10, dtype="float32") print(x.numpy())
Outputs:
[4 5 0 7 3 8 6 1 9 2] [3. 4. 9. 0. 6. 8. 7. 1. 5. 2.]