I have a (square) pairwise distances matrix, say n x n
, and I would like to get rid of the diagonal and hence work with a n x (n - 1)
matrix. What’s a fast way of doing that?
One way is a.masked_select(~torch.eye(n, dtype=bool)).view(n, n - 1)
but I was curious if there’s a faster approach.