I have a NM matrix of images where each row of M values represents a vector. I would like to compare these vectors with each other for which I am using pdist method as shown below. This method returns a 1-D tensor and I am not able find the index of any 2 vectors that matched completely (distance = 0). Is there a way I can get a NN matrix from this 1-D array?
a = torch.nn.functional.pdist(torch.rand(10, 10), p=2)
(a == 0).nonzero(as_tuple=True)[0]
As described in the docs, pdist is identical to the upper triangular portion, excluding the diagonal, of torch.norm(input[:, None] - input, dim=2, p=p)so you should be able to remap these values to these indices if needed.