{"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/moca-self-supervised-representation-learning","title":"MOCA: Self-supervised Representation Learning by Predicting Masked Online Codebook Assignments","arxiv_id":"2307.09361","date":"2023-07-18","proceeding":null,"authors":["Spyros Gidaris","Andrei Bursuc","Oriane Simeoni","Antonin Vobecky","Nikos Komodakis","Matthieu Cord","Patrick Pérez"],"abstract":"Self-supervised learning can be used for mitigating the greedy needs of Vision Transformer networks for very large fully-annotated datasets. Different classes of self-supervised learning offer representations with either good contextual reasoning properties, e.g., using masked image modeling strategies, or invariance to image perturbations, e.g., with contrastive methods. In this work, we propose a single-stage and standalone method, MOCA, which unifies both desired properties using novel mask-and-predict objectives defined with high-level features (instead of pixel-level details). Moreover, we show how to effectively employ both learning paradigms in a synergistic and computation-efficient way. Doing so, we achieve new state-of-the-art results on low-shot settings and strong experimental results in various evaluation protocols with a training that is at least 3 times faster than prior methods. We provide the implementation code at https://github.com/valeoai/MOCA.","url_abs":"https://arxiv.org/abs/2307.09361v2","url_pdf":"https://arxiv.org/pdf/2307.09361v2.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":"moca-self-supervised-representation-learning","repo_url":"https://github.com/valeoai/moca","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"NOASSERTION"}}],"tasks":[{"task_slug":"representation-learning","task_name":"Representation Learning"},{"task_slug":"self-supervised-learning","task_name":"Self-Supervised Learning"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"},{"method_slug":"vision-transformer","method_name":"Vision Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2307.09361","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2307.09361"}},"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/valeoai/moca","reach":{"status":"ok","spdx":"NOASSERTION"}}],"summary":{"ran_honours":1,"ran":11,"ran_fixture":1,"unverified":2},"by_repo_kind":{"official":{"samples":15,"ran":13,"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":15,"samples":[{"code_sha256_prefix":"bd3578806ecf5ac2","entry":"adjust_learning_rate","repo":"valeoai/moca","repo_kind":"official","path":"eval_finetune.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/eval_finetune.py","link_basis":"harvester_set","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":"bd3578806ecf5ac2"}},{"code_sha256_prefix":"3dc19396537db789","entry":"all_reduce_mean","repo":"valeoai/moca","repo_kind":"official","path":"util/misc.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/util/misc.py","link_basis":"harvester_set","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":"3dc19396537db789"}},{"code_sha256_prefix":"57889d72f516d105","entry":"buildLabelIndex","repo":"valeoai/moca","repo_kind":"official","path":"util/data_utils.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/util/data_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"57889d72f516d105"}},{"code_sha256_prefix":"9d24fe78509853ec","entry":"build_dataset","repo":"valeoai/moca","repo_kind":"official","path":"eval_finetune.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/eval_finetune.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"9d24fe78509853ec"}},{"code_sha256_prefix":"ae21f98447467f18","entry":"build_transform","repo":"valeoai/moca","repo_kind":"official","path":"eval_finetune.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/eval_finetune.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"ae21f98447467f18"}},{"code_sha256_prefix":"3c7b9c20481fa62f","entry":"concat_all_gather","repo":"valeoai/moca","repo_kind":"official","path":"util/misc.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/util/misc.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"3c7b9c20481fa62f"}},{"code_sha256_prefix":"5c8ea92d43ead77d","entry":"get_1d_sincos_pos_embed_from_grid","repo":"valeoai/moca","repo_kind":"official","path":"util/model_utils.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/util/model_utils.py","link_basis":"harvester_set","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":"5c8ea92d43ead77d"}},{"code_sha256_prefix":"77e8a3ac46f3afec","entry":"get_2d_sincos_pos_embed","repo":"valeoai/moca","repo_kind":"official","path":"util/model_utils.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/util/model_utils.py","link_basis":"harvester_set","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":"77e8a3ac46f3afec"}},{"code_sha256_prefix":"d5a2c7c5c6f12965","entry":"knn_classifier","repo":"valeoai/moca","repo_kind":"official","path":"util/knn_utils.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/util/knn_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"d5a2c7c5c6f12965"}},{"code_sha256_prefix":"d9dc385a3c9e906e","entry":"prepare_knn_imagenet_datasets","repo":"valeoai/moca","repo_kind":"official","path":"util/data_utils.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/util/data_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"d9dc385a3c9e906e"}},{"code_sha256_prefix":"a532283a514e44c5","entry":"preprocess_embeddings","repo":"valeoai/moca","repo_kind":"official","path":"eval_lowshot_logistic.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/eval_lowshot_logistic.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"a532283a514e44c5"}},{"code_sha256_prefix":"3aa8a268d0817a99","entry":"reduce_all","repo":"valeoai/moca","repo_kind":"official","path":"util/misc.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/util/misc.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"3aa8a268d0817a99"}},{"code_sha256_prefix":"3fcd69d9585e3775","entry":"subset_of_ImageNet_train_split","repo":"valeoai/moca","repo_kind":"official","path":"util/data_utils.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/util/data_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"3fcd69d9585e3775"}},{"code_sha256_prefix":"2884deadbb637c3e","entry":"get_2d_sincos_pos_embed_from_grid","repo":"valeoai/moca","repo_kind":"official","path":"util/model_utils.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/util/model_utils.py","link_basis":"harvester_set","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":"2884deadbb637c3e"}},{"code_sha256_prefix":"6ce1dce0cfb1a538","entry":"init_data","repo":"valeoai/moca","repo_kind":"official","path":"eval_lowshot_logistic.py","file_url":"https://github.com/valeoai/moca/blob/HEAD/eval_lowshot_logistic.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"6ce1dce0cfb1a538"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}