{"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/energy-based-contrastive-learning-of-visual","title":"Energy-Based Contrastive Learning of Visual Representations","arxiv_id":"2202.04933","date":"2022-02-10","proceeding":null,"authors":["Beomsu Kim","Jong Chul Ye"],"abstract":"Contrastive learning is a method of learning visual representations by training Deep Neural Networks (DNNs) to increase the similarity between representations of positive pairs (transformations of the same image) and reduce the similarity between representations of negative pairs (transformations of different images). Here we explore Energy-Based Contrastive Learning (EBCLR) that leverages the power of generative learning by combining contrastive learning with Energy-Based Models (EBMs). EBCLR can be theoretically interpreted as learning the joint distribution of positive pairs, and it shows promising results on small and medium-scale datasets such as MNIST, Fashion-MNIST, CIFAR-10, and CIFAR-100. Specifically, we find EBCLR demonstrates from X4 up to X20 acceleration compared to SimCLR and MoCo v2 in terms of training epochs. Furthermore, in contrast to SimCLR, we observe EBCLR achieves nearly the same performance with 254 negative pairs (batch size 128) and 30 negative pairs (batch size 16) per positive pair, demonstrating the robustness of EBCLR to small numbers of negative pairs. Hence, EBCLR provides a novel avenue for improving contrastive learning methods that usually require large datasets with a significant number of negative pairs per iteration to achieve reasonable performance on downstream tasks. Code: https://github.com/1202kbs/EBCLR","url_abs":"https://arxiv.org/abs/2202.04933v2","url_pdf":"https://arxiv.org/pdf/2202.04933v2.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":"energy-based-contrastive-learning-of-visual","repo_url":"https://github.com/1202kbs/ebclr","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":"self-supervised-learning","task_name":"Self-Supervised Learning"}],"methods":[{"method_slug":"1x1-convolution","method_name":"1x1 Convolution"},{"method_slug":"average-pooling","method_name":"Average Pooling"},{"method_slug":"batch-normalization","method_name":"Batch Normalization"},{"method_slug":"bottleneck-residual-block","method_name":"Bottleneck Residual Block"},{"method_slug":"colorjitter","method_name":"ColorJitter"},{"method_slug":"contrastive-learning","method_name":"Contrastive Learning"},{"method_slug":"convolution","method_name":"Convolution"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"feedforward-network","method_name":"Feedforward Network"},{"method_slug":"global-average-pooling","method_name":"Global Average Pooling"},{"method_slug":"infonce","method_name":"InfoNCE"},{"method_slug":"kaiming-initialization","method_name":"Kaiming Initialization"},{"method_slug":"max-pooling","method_name":"Max Pooling"},{"method_slug":"moco","method_name":"MoCo"},{"method_slug":"moco-v2","method_name":"MoCo v2"},{"method_slug":"nt-xent","method_name":"NT-Xent"},{"method_slug":"random-gaussian-blur","method_name":"Random Gaussian Blur"},{"method_slug":"random-resized-crop","method_name":"Random Resized Crop"},{"method_slug":"relu","method_name":"ReLU"},{"method_slug":"residual-block","method_name":"Residual Block"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"simclr","method_name":"SimCLR"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2202.04933","atlas_url":"https://app.syntology.ai/?focus=2202.04933","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2202.04933"}},"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/1202kbs/ebclr","reach":null}],"summary":{"ran":4,"ran_draft_wrong":5,"ran_honours":1,"ran_fixture":2,"unverified":2},"by_repo_kind":{"official":{"samples":14,"ran":12,"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":14,"samples":[{"code_sha256_prefix":"6ac1e9429f4fe7fa","entry":"Buffer","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6ac1e9429f4fe7fa"}},{"code_sha256_prefix":"d4ea33d3221533f2","entry":"GaussianBlur","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d4ea33d3221533f2"}},{"code_sha256_prefix":"1445124b9a9a3222","entry":"MSGLD","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1445124b9a9a3222"}},{"code_sha256_prefix":"7dae9e689051c347","entry":"SimCLR_Loss","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7dae9e689051c347"}},{"code_sha256_prefix":"9917282e521dbb6b","entry":"get_lr_schedule","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9917282e521dbb6b"}},{"code_sha256_prefix":"04f4732de0a195ef","entry":"get_optimizer","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"04f4732de0a195ef"}},{"code_sha256_prefix":"971f12d0a863e889","entry":"get_t","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"971f12d0a863e889"}},{"code_sha256_prefix":"fdcbd4afb30b8c3f","entry":"load_ckpt","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"fdcbd4afb30b8c3f"}},{"code_sha256_prefix":"a5d7c8bbd5782ef5","entry":"logsumexp","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a5d7c8bbd5782ef5"}},{"code_sha256_prefix":"507b89409e45c9af","entry":"shuffled_idx","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"507b89409e45c9af"}},{"code_sha256_prefix":"5f603a9f2e80d384","entry":"similarity_f","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5f603a9f2e80d384"}},{"code_sha256_prefix":"a93280fc29bbdbef","entry":"transform_data","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a93280fc29bbdbef"}},{"code_sha256_prefix":"aad3c0e761fa8f19","entry":"EBCLR","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"aad3c0e761fa8f19"}},{"code_sha256_prefix":"dd7d00639441fd9d","entry":"save_ckpt","repo":"1202kbs/ebclr","repo_kind":"official","path":"libs/ebclr.py","file_url":"https://github.com/1202kbs/ebclr/blob/HEAD/libs/ebclr.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"dd7d00639441fd9d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}