Solved by ptrblck in post #2 
              
              
                You could calculate the distance between the tensors using torch.norm and use argmin to get the index corresponding to the smallest distance: 
a = torch.stack([torch.tensor([1,1,1]), torch.tensor([5,5,5]), torch.tensor([10,10,10])]).float()
b = torch.tensor([2,2,2]).float()
min_idx = torch.norm(a - …