My objective it to count all adjacent unique values of a tensor x.
Say my tensor is (x looks like a list but it is a pytorch tensor)
x = [1,2,1,2,4,5]
I would want my output to be:
[1,2] = 2
[2,1] = 1
[2,4] = 1
[4,5] = 1
I thought about changing the dimensionality of the tensor to look like:
x = [[1,2],[2,1],[1,2],[2,4],[4,5]]
using tensor.view but couldn't find a solution that works for a tensor of any length.
Any ideas if this is even the best way to go about this? is there some built-in function?