Cysu / open-reid

Open source person re-identification library in python
https://cysu.github.io/open-reid/
MIT License
1.34k stars 349 forks source link

question about evaluators.py #9

Closed Kevin35Day closed 7 years ago

Kevin35Day commented 7 years ago

hi!

in the open-reid/reid/evaluators.py

def pairwise_distance(features, query=None, gallery=None, metric=None):
if query is None and gallery is None:
n = len(features)
x = torch.cat(list(features.values()))
x = x.view(n, -1)
if metric is not None:
x = metric.transform(x)
dist = torch.pow(x, 2).sum(1) * 2
dist = dist.expand(n, n) - 2 * torch.mm(x, x.t())
return dist

the result seems not euclidean metric? in this 'pairwise_distance' function,the second part is computing euclidean metric,but the first part looks not right? why they are different?

thanks!

Cysu commented 7 years ago

Say we have a matrix X with N samples. The first part actually computes the pairwise distances inside X, resulting in a NxN distance matrix.

Say we have another matrix Y with M samples. The second part actually computes the pairwise distance across X and Y, resulting in a NxM matrix.