{"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/targeted-supervised-contrastive-learning-for","title":"Targeted Supervised Contrastive Learning for Long-Tailed Recognition","arxiv_id":"2111.13998","date":"2021-11-27","proceeding":"CVPR 2022 1","authors":["Tianhong Li","Peng Cao","Yuan Yuan","Lijie Fan","Yuzhe Yang","Rogerio Feris","Piotr Indyk","Dina Katabi"],"abstract":"Real-world data often exhibits long tail distributions with heavy class imbalance, where the majority classes can dominate the training process and alter the decision boundaries of the minority classes. Recently, researchers have investigated the potential of supervised contrastive learning for long-tailed recognition, and demonstrated that it provides a strong performance gain. In this paper, we show that while supervised contrastive learning can help improve performance, past baselines suffer from poor uniformity brought in by imbalanced data distribution. This poor uniformity manifests in samples from the minority class having poor separability in the feature space. To address this problem, we propose targeted supervised contrastive learning (TSC), which improves the uniformity of the feature distribution on the hypersphere. TSC first generates a set of targets uniformly distributed on a hypersphere. It then makes the features of different classes converge to these distinct and uniformly distributed targets during training. This forces all classes, including minority classes, to maintain a uniform distribution in the feature space, improves class boundaries, and provides better generalization even in the presence of long-tail data. Experiments on multiple datasets show that TSC achieves state-of-the-art performance on long-tailed recognition tasks.","url_abs":"https://arxiv.org/abs/2111.13998v2","url_pdf":"https://arxiv.org/pdf/2111.13998v2.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":"targeted-supervised-contrastive-learning-for","repo_url":"https://github.com/lth14/targeted-supcon","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"contrastive-learning","task_name":"Contrastive Learning"},{"task_slug":"long-tail-learning","task_name":"Long-tail Learning"}],"methods":[{"method_slug":"contrastive-learning","method_name":"Contrastive Learning"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/long-tail-learning-on-cifar-10-lt-r-10","task":"Long-tail Learning","dataset":"CIFAR-10-LT (ρ=10)","model":"TSC","rank_in_archive_order":33,"of":50,"metrics":{"Error Rate":"11.3"},"uses_additional_data":false},{"leaderboard":"/sota/long-tail-learning-on-cifar-10-lt-r-100","task":"Long-tail Learning","dataset":"CIFAR-10-LT (ρ=100)","model":"TSC(ResNet-32)","rank_in_archive_order":24,"of":28,"metrics":{"Error Rate":"21.3"},"uses_additional_data":false},{"leaderboard":"/sota/long-tail-learning-on-cifar-100-lt-r-100","task":"Long-tail Learning","dataset":"CIFAR-100-LT (ρ=100)","model":"TSC(ResNet-32)","rank_in_archive_order":54,"of":66,"metrics":{"Error Rate":"56.2"},"uses_additional_data":false},{"leaderboard":"/sota/long-tail-learning-on-imagenet-lt","task":"Long-tail Learning","dataset":"ImageNet-LT","model":"TSC(ResNet-50)","rank_in_archive_order":49,"of":69,"metrics":{"Top-1 Accuracy":"52.4"},"uses_additional_data":false},{"leaderboard":"/sota/long-tail-learning-on-inaturalist-2018","task":"Long-tail Learning","dataset":"iNaturalist 2018","model":"TSC(ResNet-50)","rank_in_archive_order":36,"of":43,"metrics":{"Top-1 Accuracy":"69.7%"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2111.13998","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2111.13998"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+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/lth14/targeted-supcon","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_fixture":1,"unverified":13},"by_repo_kind":{"official":{"samples":14,"ran":1,"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":"131a82fd65128218","entry":"accuracy","repo":"lth14/targeted-supcon","repo_kind":"official","path":"main_moco_supcon_imba.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/main_moco_supcon_imba.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"131a82fd65128218"}},{"code_sha256_prefix":"75b34b1b9cfea207","entry":"adjust_learning_rate","repo":"lth14/targeted-supcon","repo_kind":"official","path":"main_moco_supcon_imba.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/main_moco_supcon_imba.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"75b34b1b9cfea207"}},{"code_sha256_prefix":"69e2ce68b6db2411","entry":"alexnet","repo":"lth14/targeted-supcon","repo_kind":"official","path":"moco_models/alexnet.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/moco_models/alexnet.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"69e2ce68b6db2411"}},{"code_sha256_prefix":"9eb4b3b03ed7a1c9","entry":"densenet121","repo":"lth14/targeted-supcon","repo_kind":"official","path":"moco_models/densenet.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/moco_models/densenet.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9eb4b3b03ed7a1c9"}},{"code_sha256_prefix":"e945c7af558f65a9","entry":"densenet161","repo":"lth14/targeted-supcon","repo_kind":"official","path":"moco_models/densenet.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/moco_models/densenet.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e945c7af558f65a9"}},{"code_sha256_prefix":"858b62a0718acf3c","entry":"densenet169","repo":"lth14/targeted-supcon","repo_kind":"official","path":"moco_models/densenet.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/moco_models/densenet.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"858b62a0718acf3c"}},{"code_sha256_prefix":"a117231916d15cb9","entry":"get_data_transform","repo":"lth14/targeted-supcon","repo_kind":"official","path":"dataset/imagenet.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/dataset/imagenet.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a117231916d15cb9"}},{"code_sha256_prefix":"cc86d582f7c75a6d","entry":"googlenet","repo":"lth14/targeted-supcon","repo_kind":"official","path":"moco_models/googlenet.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/moco_models/googlenet.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cc86d582f7c75a6d"}},{"code_sha256_prefix":"4826cd3596c12660","entry":"init_weights","repo":"lth14/targeted-supcon","repo_kind":"official","path":"imagenet_inat/utils.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/imagenet_inat/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4826cd3596c12660"}},{"code_sha256_prefix":"457c95f8c16efe85","entry":"load_data_imagenet","repo":"lth14/targeted-supcon","repo_kind":"official","path":"dataset/imagenet.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/dataset/imagenet.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"457c95f8c16efe85"}},{"code_sha256_prefix":"215b209f49176d4e","entry":"parse_option_stage1","repo":"lth14/targeted-supcon","repo_kind":"official","path":"cifar_dirty/main_supcon_imba.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/cifar_dirty/main_supcon_imba.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"215b209f49176d4e"}},{"code_sha256_prefix":"985b6559d5dbe2f7","entry":"shot_acc","repo":"lth14/targeted-supcon","repo_kind":"official","path":"imagenet_inat/utils.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/imagenet_inat/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"985b6559d5dbe2f7"}},{"code_sha256_prefix":"07cca9631fe4f26a","entry":"source_import","repo":"lth14/targeted-supcon","repo_kind":"official","path":"imagenet_inat/utils.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/imagenet_inat/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"07cca9631fe4f26a"}},{"code_sha256_prefix":"a7758cbaed64d10d","entry":"validate","repo":"lth14/targeted-supcon","repo_kind":"official","path":"main_lincls_imba.py","file_url":"https://github.com/lth14/targeted-supcon/blob/HEAD/main_lincls_imba.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a7758cbaed64d10d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}