Skip to content
Advertisement

torch.unique does not work for float tensors

I am trying to extract the unique elements from a float tensor. I have tried :

JavaScript

However this method only works for int/long tensor. My tensor is quantizied tensor in a non-uniform way, thus its guaranteed to have a small set of float values.

Advertisement

Answer

You could using numpy.unique instead

JavaScript

Outputs:

JavaScript
Advertisement