Returns a tensor with a random permutation of integers from `0` to `n-1`. ```python exec="true" source="above" session="tensor" result="python" Tensor.manual_seed(42) print(Tensor.randperm(6).numpy()) ```
(n:int, device=None, dtype=dtypes.int32, **kwargs)
| 785 | |
| 786 | @staticmethod |
| 787 | def randperm(n:int, device=None, dtype=dtypes.int32, **kwargs) -> Tensor: |
| 788 | """ |
| 789 | Returns a tensor with a random permutation of integers from `0` to `n-1`. |
| 790 | |
| 791 | ```python exec="true" source="above" session="tensor" result="python" |
| 792 | Tensor.manual_seed(42) |
| 793 | print(Tensor.randperm(6).numpy()) |
| 794 | ``` |
| 795 | """ |
| 796 | return Tensor.rand(n, device=device, **kwargs).argsort().cast(dtype) |
| 797 | |
| 798 | def multinomial(self:Tensor, num_samples:int = 1, replacement:bool = False) -> Tensor: |
| 799 | """ |