Загрузка
Returns the unique elements of the input tensor.
input (Tensor) – the input tensor
sorted (bool) – Whether to sort the unique elements in ascending order before returning as output.
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, optional) – the dimension to operate upon. If None, the
unique of the flattened input is returned. Otherwise, each of the
tensors indexed by the given dimension is treated as one of the
elements to apply the unique operation upon. Important: when
is specified, the operation finds unique sub-tensors (e.g., unique rows
or columns), not unique scalar values. This means individual values may
appear multiple times in the output if they exist in different sub-tensors.
See examples for more details. Default:
A tensor or a tuple of tensors containing
output (Tensor): the output list of unique scalar elements if
dimisNone; otherwise, the unique sub-tensors along the specified dimension. Note that whendimis specified, scalar values may repeat in the output.inverse_indices (Tensor): (optional) if
return_inverseis True, there will be an additional returned tensor (same shape as input) representing the indices for where elements in the original input map to in the output; otherwise, this function will only return a single tensor.counts (Tensor): (optional) if
return_countsis True, there will be an additional returned tensor (same shape as output or output.size(dim), if dim was specified) representing the number of occurrences for each unique value or tensor.
Example:
>>> output = torch.unique(torch.tensor([1, 3, 2, 3], dtype=torch.long))
>>> output
tensor([1, 2, 3])
>>> output, inverse_indices = torch.unique
None