powered by
Combinations
torch_combinations(self, r = 2L, with_replacement = FALSE)
(Tensor) 1D vector.
(int, optional) number of elements to combine
(boolean, optional) whether to allow duplication in combination
Compute combinations of length \(r\) of the given tensor. The behavior is similar to python's itertools.combinations when with_replacement is set to False, and itertools.combinations_with_replacement when with_replacement is set to TRUE.
itertools.combinations
with_replacement
False
itertools.combinations_with_replacement
TRUE
if (torch_is_installed()) { a = c(1, 2, 3) tensor_a = torch_tensor(a) torch_combinations(tensor_a) torch_combinations(tensor_a, r=3) torch_combinations(tensor_a, with_replacement=TRUE) }
Run the code above in your browser using DataLab