Hi Frank,
I can’t quite follow you. What I want is to map index matrix a.
This is how to do it in numpy, but I just wonder is there a way to do it in Pytorch？
a = torch.randint (10, 100, (10, 10))
b = a.numpy()
old_index = np.unique(b)
new_index = np.arange(len(old_index))
index_map = dict(zip(old_index, new_index))

np.vectorize(index_map.get)(b)