dgs.models.metric.metric

Methods for handling the computation of distances and other metrics.

Module Functions

compute_accuracy(prediction, target[, topk])

Compute the accuracies of a predictor over a tuple of k-top predictions.

compute_cmc(distmat, query_pids, ...)

Compute the cumulative matching characteristics metric.

compute_near_k_accuracy(a_pred, a_targ, ks)

Compute the number of correct predictions within a margin of k percent for all k.

custom_cosine_similarity(input1, input2, ...)

See https://github.com/pytorch/pytorch/issues/104564#issuecomment-1625348908

Module Classes

CosineDistanceMetric(*args, **kwargs)

Class to compute the cosine distance between two matrices.

CosineSimilarityMetric(*args, **kwargs)

Class to compute the cosine similarity between two matrices.

EuclideanDistanceMetric(*args, **kwargs)

Class to compute the Euclidean distance between two matrices.

EuclideanSquareMetric(*args, **kwargs)

Class to compute the squared Euclidean distance between two matrices.

IOUDistance(*args, **kwargs)

Class to compute the intersection-over-union distance.

NegativeSoftmaxEuclideanDistance(*args, **kwargs)

Class to compute the Softmax distribution of the negative Euclidean distance.

NegativeSoftmaxEuclideanSquaredDistance(...)

Class to compute the Softmax distribution of the negative squared Euclidean distance.

PairwiseDistanceMetric(*args, **kwargs)

Class to compute the pairwise distance.

TorchreidCosineDistance(*args, **kwargs)

Call TorchReid's version of the cosine distance.

TorchreidEuclideanSquaredDistance(*args, ...)

Call TorchReid's version of the Euclidean squared distance.