PyTorch Metric Learning has seen a lot of changes in the past few months. Here are the highlights.

Distances, Reducers, and Regularizers

Loss functions are now highly customizable with the introduction of distances, reducers, and regularizers.


I recently uploaded a new version of A Metric Learning Reality Check to arXiv. Here are the highlights:

Unfair Comparisons: Concrete Examples

People were asking for examples to back up my claims about unfair comparisons, so I created a list of examples. See the screenshots below.

Click here to view the list with working links


Go here for the code and latest updates, and check out the associated paper, A Metric Learning Reality Check.

The typical metric learning paper presents a new loss function or training procedure, and then shows results on a few datasets, like CUB200, Stanford Cars, and Stanford Online Products. Every couple of months, we see the accuracy improve like clockwork.

Great, but there are a few caveats.

Here’s a random graph to keep your attention

Some papers do not compare apples to apples

In order to claim that a new algorithm outperforms existing methods, it’s important to keep as many parameters constant as possible. That way, we can be certain that it was the new algorithm that…


Have you thought of using a metric learning approach in your deep learning application? If not, this is an approach you may find useful, especially if your deployed model will encounter unseen classes of data.

With the release of pytorch-metric-learning, it’s easier than ever to give metric learning a try!

Samples from the CUB200 dataset, a commonly-used metric learning benchmark

What is Metric Learning?

Metric Learning refers to the task of learning distances or dissimilarities over a set of observations. We want to find a function that returns a small distance for similar observations and a large distance for different ones.

Why use this package?

Ease of use

  • Add metric learning to your application with just 2 lines…

Kevin Musgrave

Computer science PhD student @ Cornell University (Cornell Tech). KevinMusgrave.com https://github.com/KevinMusgrave

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store