{"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/robust-contrastive-learning-using-negative","title":"Robust Contrastive Learning Using Negative Samples with Diminished Semantics","arxiv_id":"2110.14189","date":"2021-10-27","proceeding":"NeurIPS 2021 12","authors":["Songwei Ge","Shlok Mishra","Haohan Wang","Chun-Liang Li","David Jacobs"],"abstract":"Unsupervised learning has recently made exceptional progress because of the development of more effective contrastive learning methods. However, CNNs are prone to depend on low-level features that humans deem non-semantic. This dependency has been conjectured to induce a lack of robustness to image perturbations or domain shift. In this paper, we show that by generating carefully designed negative samples, contrastive learning can learn more robust representations with less dependence on such features. Contrastive learning utilizes positive pairs that preserve semantic information while perturbing superficial features in the training images. Similarly, we propose to generate negative samples in a reversed way, where only the superfluous instead of the semantic features are preserved. We develop two methods, texture-based and patch-based augmentations, to generate negative samples. These samples achieve better generalization, especially under out-of-domain settings. We also analyze our method and the generated texture-based samples, showing that texture features are indispensable in classifying particular ImageNet classes and especially finer classes. We also show that model bias favors texture and shape features differently under different test settings. Our code, trained models, and ImageNet-Texture dataset can be found at https://github.com/SongweiGe/Contrastive-Learning-with-Non-Semantic-Negatives.","url_abs":"https://arxiv.org/abs/2110.14189v2","url_pdf":"https://arxiv.org/pdf/2110.14189v2.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":"robust-contrastive-learning-using-negative","repo_url":"https://github.com/SongweiGe/Contrastive-Learning-with-Non-Semantic-Negatives","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"contrastive-learning","task_name":"Contrastive Learning"},{"task_slug":"data-augmentation","task_name":"Data Augmentation"},{"task_slug":"self-supervised-learning","task_name":"Self-Supervised Learning"}],"methods":[{"method_slug":"contrastive-learning","method_name":"Contrastive Learning"},{"method_slug":"test","method_name":"Test"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2110.14189","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2110.14189"}},"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/SongweiGe/Contrastive-Learning-with-Non-Semantic-Negatives","reach":null}],"summary":{"ran":2,"ran_fixture":2},"by_repo_kind":{"official":{"samples":4,"ran":4,"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":"14a01928514fd931","entry":"NonSemanticAug","repo":"SongweiGe/Contrastive-Learning-with-Non-Semantic-Negatives","repo_kind":"official","path":"moco/loader.py","file_url":"https://github.com/SongweiGe/Contrastive-Learning-with-Non-Semantic-Negatives/blob/HEAD/moco/loader.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"14a01928514fd931"}},{"code_sha256_prefix":"c481f50cea80abbf","entry":"RandomRotation","repo":"SongweiGe/Contrastive-Learning-with-Non-Semantic-Negatives","repo_kind":"official","path":"moco/loader.py","file_url":"https://github.com/SongweiGe/Contrastive-Learning-with-Non-Semantic-Negatives/blob/HEAD/moco/loader.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c481f50cea80abbf"}},{"code_sha256_prefix":"131a82fd65128218","entry":"accuracy","repo":"songweige/contrastive-learning-with-non-semantic-negatives","repo_kind":"official","path":"moco-non-sem-neg.py","file_url":"https://github.com/songweige/contrastive-learning-with-non-semantic-negatives/blob/HEAD/moco-non-sem-neg.py","link_basis":"first_harvest_node","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":"63ce1d5edf8fb0a0","entry":"validate","repo":"songweige/contrastive-learning-with-non-semantic-negatives","repo_kind":"official","path":"main_lincls.py","file_url":"https://github.com/songweige/contrastive-learning-with-non-semantic-negatives/blob/HEAD/main_lincls.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"63ce1d5edf8fb0a0"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}