Argsort
Source:R/gen-namespace-docs.R
, R/gen-namespace-examples.R
, R/with-indices.R
torch_argsort.Rd
Argsort
Arguments
- self
(Tensor) the input tensor.
- dim
(int, optional) the dimension to sort along
- descending
(bool, optional) controls the sorting order (ascending or descending)
argsort(input, dim=-1, descending=False) -> LongTensor
Returns the indices that sort a tensor along a given dimension in ascending order by value.
This is the second value returned by torch_sort
. See its documentation
for the exact semantics of this method.
Examples
if (torch_is_installed()) {
a = torch_randn(c(4, 4))
a
torch_argsort(a, dim=1)
}
#> torch_tensor
#> 1 2 1 2
#> 2 4 2 1
#> 3 3 4 4
#> 4 1 3 3
#> [ CPULongType{4,4} ]