Interpolate one range of numbers to another in a tensor in PyTorch
I am trying to transform a set of numbers say {0, 4, 6} to a consecutive one {0, 1, 2}.
Currently I am using Scipy's interp1d function. My problem is that I want to change each element of a tensor. Is there a better way than broadcasting the interp1d function to each element in a tensor? If not how can I achieve this broadcasting of a custom function

Currently I am doing the following: 

&gt;&gt;&gt; a = torch.tensor([[0, 6, 4],
                      [4, 0, 4]])
&gt;&gt;&gt; unique_values = np.unique(a)
&gt;&gt;&gt; interpolator = interp1d(unique_values, range(len(unique_values)))
&gt;&gt;&gt; interpolator(a[0, 1])
&gt;&gt;&gt; 2


If you just want to replace, why do you want to interpolate?

a[a==6]=2
a[a==4]=1


Should work. If you don't want to hardcode, you can find unique values like you did, sort them and then replace them in a loop. 
