Unique_consecutive
Source:R/gen-namespace-docs.R
, R/gen-namespace-examples.R
, R/gen-namespace.R
torch_unique_consecutive.Rd
Unique_consecutive
Arguments
- self
(Tensor) the input tensor
- return_inverse
(bool) Whether to also return the indices for where elements in the original input ended up in the returned unique list.
- return_counts
(bool) Whether to also return the counts for each unique element.
- dim
(int) the dimension to apply unique. If
NULL
, the unique of the flattened input is returned. default:NULL
Examples
if (torch_is_installed()) {
x = torch_tensor(c(1, 1, 2, 2, 3, 1, 1, 2))
output = torch_unique_consecutive(x)
output
torch_unique_consecutive(x, return_inverse=TRUE)
torch_unique_consecutive(x, return_counts=TRUE)
}
#> [[1]]
#> torch_tensor
#> 1
#> 2
#> 3
#> 1
#> 2
#> [ CPUFloatType{5} ]
#>
#> [[2]]
#> torch_tensor
#> [ CPULongType{0} ]
#>
#> [[3]]
#> torch_tensor
#> 2
#> 2
#> 1
#> 2
#> 1
#> [ CPULongType{5} ]
#>