Efficient Distance Matrix Computation

@AtheMathmo: For pytorch version 0.2.0_4 (I’m not sure about the latest pytorch version), I found that torch.clamp(dist, 0.0, np.inf) didn’t deal with nan values that sometimes arises along the diagonal when running pairwise_distances(x, y=None). To mitigate this issue, I replaced the line with the following:

dist[dist != dist] = 0 # replace nan values with 0

2 Likes