Hello,
I have two questions regarding the unique
function:
1- I figured out that in Pytorch documentation for unique function when sorted is not provided according to the example given in the documentation the default of it is false:
output = torch.unique(torch.tensor([1, 3, 2, 3], dtype=torch.long))
output
tensor([ 2, 3, 1])
However, in my computer I get:
torch.unique(torch.tensor([1, 3, 2, 3], dtype=torch.long))
tensor([1, 2, 3])
, which means that the default value of sorted=True. Where does this inconsistency come from?
2- Moreover, I figured out that the output of
torch.unique(torch.tensor([1, 3, 2, 3], dtype=torch.long), sorted=False)
is
tensor([2, 3, 1])
, which means that it doesn’t even keep the order of occurrence. How can I have a unique function that keeps track of the first occurrence of elements? I mean, with the above example, the output should be:
tensor([1, 3, 2])