{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/it-takes-two-to-tango-mixup-for-deep-metric","title":"It Takes Two to Tango: Mixup for Deep Metric Learning","arxiv_id":"2106.04990","date":"2021-06-09","proceeding":"ICLR 2022 4","authors":["Shashanka Venkataramanan","Bill Psomas","Ewa Kijak","Laurent Amsaleg","Konstantinos Karantzalos","Yannis Avrithis"],"abstract":"Metric learning involves learning a discriminative representation such that embeddings of similar classes are encouraged to be close, while embeddings of dissimilar classes are pushed far apart. State-of-the-art methods focus mostly on sophisticated loss functions or mining strategies. On the one hand, metric learning losses consider two or more examples at a time. On the other hand, modern data augmentation methods for classification consider two or more examples at a time. The combination of the two ideas is under-studied. In this work, we aim to bridge this gap and improve representations using mixup, which is a powerful data augmentation approach interpolating two or more examples and corresponding target labels at a time. This task is challenging because unlike classification, the loss functions used in metric learning are not additive over examples, so the idea of interpolating target labels is not straightforward. To the best of our knowledge, we are the first to investigate mixing both examples and target labels for deep metric learning. We develop a generalized formulation that encompasses existing metric learning loss functions and modify it to accommodate for mixup, introducing Metric Mix, or Metrix. We also introduce a new metric - utilization, to demonstrate that by mixing examples during training, we are exploring areas of the embedding space beyond the training classes, thereby improving representations. To validate the effect of improved representations, we show that mixing inputs, intermediate representations or embeddings along with target labels significantly outperforms state-of-the-art metric learning methods on four benchmark deep metric learning datasets.","url_abs":"https://arxiv.org/abs/2106.04990v2","url_pdf":"https://arxiv.org/pdf/2106.04990v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"it-takes-two-to-tango-mixup-for-deep-metric","repo_url":"https://github.com/billpsomas/Metrix_ICLR22","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"data-augmentation","task_name":"Data Augmentation"},{"task_slug":"metric-learning","task_name":"Metric Learning"},{"task_slug":"representation-learning","task_name":"Representation Learning"},{"task_slug":"two","task_name":"Vocal Bursts Valence Prediction"}],"methods":[{"method_slug":"metrix","method_name":"Metrix"}],"datasets_introduced":[],"methods_introduced":[{"slug":"metrix","name":"Metrix","full_name":"Metric mixup"}],"results":[{"leaderboard":"/sota/metric-learning-on-cars196","task":"Metric Learning","dataset":"CARS196","model":"ResNet-50 + Metrix","rank_in_archive_order":9,"of":36,"metrics":{"R@1":"89.6"},"uses_additional_data":true},{"leaderboard":"/sota/metric-learning-on-cub-200-2011","task":"Metric Learning","dataset":"CUB-200-2011","model":"ResNet-50 + Metrix","rank_in_archive_order":8,"of":30,"metrics":{"R@1":"71.4"},"uses_additional_data":true},{"leaderboard":"/sota/metric-learning-on-in-shop-1","task":"Metric Learning","dataset":"In-Shop","model":"ResNet-50 + Metrix","rank_in_archive_order":8,"of":15,"metrics":{"R@1":"92.2"},"uses_additional_data":true},{"leaderboard":"/sota/metric-learning-on-stanford-online-products-1","task":"Metric Learning","dataset":"Stanford Online Products","model":"ResNet-50 + Metrix","rank_in_archive_order":15,"of":33,"metrics":{"R@1":"81.3"},"uses_additional_data":true}],"syntology":{"syntology_url":"https://syntology.ai/paper/2106.04990","atlas_url":"https://app.syntology.ai/?focus=2106.04990","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2106.04990"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/billpsomas/Metrix_ICLR22","reach":null}],"summary":{"ran_draft_wrong":1,"ran_honours":1},"by_repo_kind":{"official":{"samples":2,"ran":2,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"0a45d2d44dcc4cee","entry":"loss_pos_mixup","repo":"billpsomas/Metrix_ICLR22","repo_kind":"official","path":"mixup/losses.py","file_url":"https://github.com/billpsomas/Metrix_ICLR22/blob/HEAD/mixup/losses.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0a45d2d44dcc4cee"}},{"code_sha256_prefix":"0c770705d3cd9afd","entry":"margin","repo":"billpsomas/Metrix_ICLR22","repo_kind":"official","path":"mixup/losses.py","file_url":"https://github.com/billpsomas/Metrix_ICLR22/blob/HEAD/mixup/losses.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0c770705d3cd9afd"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}