## Usage Example ## Example import torch # Create tensor x = torch.tensor([3,1,2]) # Return sorted indices indices = torch.argsort(x) print(indices) Output: tensor([1, 2, 0])
Pytorch Torch Argsort
# PyTorch torch.argsort Function
PyTorch torch Reference Manual
`torch.argsort` is a PyTorch function that returns indices of sorted elements. It returns the original positions of elements after sorting the tensor.
### Function Definition
torch.argsort(input, dim=-1, descending=False, stable=True)
## Usage Example ## Example import torch # Create tensor x = torch.tensor([3,1,2]) # Return sorted indices indices = torch.argsort(x) print(indices) Output: tensor([1, 2, 0])
PyTorch torch Reference Manual
PyTorch Data Transforms
PyTorch torch.nn Reference Manual
Xunfei Star Coding Plan includes free model call quotas for DeepSeek, GLM, Kimi, MiniMax. One-stop platform for experience and deployment. Configuration Guide Β₯3.9/month Sign up now
## Usage Example ## Example import torch # Create tensor x = torch.tensor([3,1,2]) # Return sorted indices indices = torch.argsort(x) print(indices) Output: tensor([1, 2, 0])
YouTip