unique¶
- dragon.vm.torch.- unique(
 input,
 return_inverse=False,
 return_counts=False,
 **kwargs
 )[source]¶
- Return the unique elements of input. - If - return_inverse, return the extra index where input mapping to:- x = torch.tensor([1, 2, 3, 2]) y, index = torch.unique(x, return_inverse=True) print(y) # [1, 2, 3] print(index) # [0, 1, 2, 1] - If - return_counts, return the extra counts of output:- x = torch.tensor([1, 2, 3, 2]) y, counts = torch.unique(x, return_counts=True) print(y) # [1, 2, 3] print(counts) # [1, 2, 1] - Parameters:
- input (dragon.vm.torch.Tensor) – The input tensor.
- return_inverse (bool, optional, default=False) – Return the inverse index or not.
- return_counts (bool, optional, default=False) – Return the counts or not.
 
 - Returns:
- dragon.vm.torch.Tensor – The output tensor.
- dragon.vm.torch.Tensor, optional – The inverse index tensor.
- dragon.vm.torch.Tensor, optional – The counts tensor.
 
 
