NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI, #2901 most downloaded on PyPI
Composable metric learning losses, miners, distances, samplers, and retrieval metrics for PyTorch.
Latest stable
3.0.3
Last release 2 days ago
13 Nov 2026
Release timing varies
gaps range from 8 days to 1.2 years
Nearly every release is documented
notes for 56 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
221 releases · first in 2019
Drag across the ruler to compare, or tap a release to open it.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Nothing published for this version
Added assertions to make sure the number of input embeddings is equal to the number of input labels.
Losses + miners
Trainers
freeze_these to the init arguments of BaseTrainer. This optional argument takes a list or tuple of strings as input. The strings must correspond to the names of models or loss functions, and these models/losses will have their parameters frozen during training. Their corresponding optimizers will also not be stepped.Testers
visualizer_hookeval option to get_all_embeddings. By default it is True, and will set the input trunk and embedder to eval() mode.Utils
<model_name>_best<epoch>.pth rather than <model_name>_best.pth. To easily get the new suffix for loading the best model you can do:from pytorch_metric_learning.utils import common_functions as c_f
_, best_model_suffix = c_f.latest_version(your_model_folder, best=True)
best_trunk = "trunk_{}.pth".format(best_model_suffix)
best_embedder = "embedder_{}.pth".format(best_model_suffix)
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Added TwoStreamMetricLoss. By @marijnl.
Trainers
BaseTrainer child classes now accept *args and pass it to BaseTrainer, so that you can use positional arguments when you init those child classes, rather than just keyword arguments.Testers
fit_transform method, rather than fit and transform separately.label_hierarchy_levelUtils
best_epoch could be None.average_per_class option, which computes the average accuracy per class, and then returns the average of those averages. This can be useful when evaluating datasets with unbalanced classes.Other stuff
with-hooks and with-hooks-cpu pip install options. The following will install record-keeper, faiss-gpu, and tensorboard, in addition to pytorch-metric-learningpip install pytorch-metric-learning[with-hooks]
If you don't have a GPU you can do:
pip install pytorch-metric-learning[with-hooks-cpu]
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Removed `size_of_tsne and added visualizer and visualizer_hook to BaseTester. The visualizer needs to implement the fit and transform functions. (In t
Testers
size_of_tsne and added visualizer and visualizer_hook to BaseTester. The visualizer needs to implement the fit and transform functions. (In the next version, I'll allow fit_transform as well.) For example:# UMAP is the dimensionality reducer we will pass in as the visualizer
import umap
import umap.plot
# For plotting the embeddings
def visualizer_hook(umapper, umap_embeddings, labels, split_name, keyname):
logging.info("UMAP plot for the {} split and label set {}".format(split_name, keyname))
umap.plot.points(umapper, labels=labels, show_legend=False)
plt.show()
GlobalEmbeddingSpaceTester(visualizer=umap.UMAP(), visualizer_hook=visualizer_hook)
Utils
include to the init arguments.exclude_metrics to exclude.requires_knn method.check_primary_metrics to AccuracyCalculator, which validates the metrics specified in include and exclude. By @wconnellprimary_metric is in tester.AccuracyCalculator. By @wconnell**kwargs to get_hook_container, so that, for example, you can do get_hook_container(record_keeper, primary_metric="AMI")Other stuff
Nothing published for this version
Nothing published for this version
Nothing published for this version
Added CircleLoss, implemented by @AlenUbuntu
Losses
normalize_embeddings=Falseminer_weights in ProxyAnchorLoss, NCALoss, and FastAPLossUtils
convert_to_weights return values between 0 and 1, where 1 represents the most frequently occuring sample. Before, it was scaling the probability by size of batch.Other stuff
convert_to_weightsNothing published for this version
Nothing published for this version
Made `iterations_per_epoch` optional. See the new documentation
Losses
Trainers
iterations_per_epoch optional. See the new documentationlr_schedulers to allow for end of iteration, end of epoch, and plateau schedulers to all be used at the same time.Utils
HookContainer
skip_eval_if_already_done flag to run_tester_separately.ignore_epoch a tuple.save_custom_figures flag.common_functions
pass_data_to_model and autograd.Variable usage.Other stuff
__version__ was not accessible.Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.