{"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/one-loss-for-all-deep-hashing-with-a-single","title":"One Loss for All: Deep Hashing with a Single Cosine Similarity based Learning Objective","arxiv_id":"2109.14449","date":"2021-09-29","proceeding":"NeurIPS 2021 12","authors":["Jiun Tian Hoe","Kam Woh Ng","Tianyu Zhang","Chee Seng Chan","Yi-Zhe Song","Tao Xiang"],"abstract":"A deep hashing model typically has two main learning objectives: to make the learned binary hash codes discriminative and to minimize a quantization error. With further constraints such as bit balance and code orthogonality, it is not uncommon for existing models to employ a large number (>4) of losses. This leads to difficulties in model training and subsequently impedes their effectiveness. In this work, we propose a novel deep hashing model with only a single learning objective. Specifically, we show that maximizing the cosine similarity between the continuous codes and their corresponding binary orthogonal codes can ensure both hash code discriminativeness and quantization error minimization. Further, with this learning objective, code balancing can be achieved by simply using a Batch Normalization (BN) layer and multi-label classification is also straightforward with label smoothing. The result is an one-loss deep hashing model that removes all the hassles of tuning the weights of various losses. Importantly, extensive experiments show that our model is highly effective, outperforming the state-of-the-art multi-loss hashing models on three large-scale instance retrieval benchmarks, often by significant margins. Code is available at https://github.com/kamwoh/orthohash","url_abs":"https://arxiv.org/abs/2109.14449v1","url_pdf":"https://arxiv.org/pdf/2109.14449v1.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":"one-loss-for-all-deep-hashing-with-a-single","repo_url":"https://github.com/kamwoh/orthohash","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"one-loss-for-all-deep-hashing-with-a-single","repo_url":"https://github.com/cisiplab/cisip-fire","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"all","task_name":"All"},{"task_slug":"deep-hashing","task_name":"Deep Hashing"},{"task_slug":"multi-label-classification-2","task_name":"MUlTI-LABEL-ClASSIFICATION"},{"task_slug":"multi-label-classification","task_name":"Multi-Label Classification"},{"task_slug":"quantization","task_name":"Quantization"},{"task_slug":"retrieval","task_name":"Retrieval"}],"methods":[{"method_slug":"batch-normalization","method_name":"Batch Normalization"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2109.14449","atlas_url":"https://app.syntology.ai/?focus=2109.14449","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2109.14449"}},"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":"deterministic:regex_extraction","url":"https://github.com/kamwoh/orthohash","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/cisiplab/cisip-fire","reach":null}],"summary":{"ran":2,"ran_fixture":1,"ran_draft_wrong":1,"unverified":2},"by_repo_kind":{"official":{"samples":3,"ran":2,"repositories":1},"listed":{"samples":3,"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":"51f777eea1887485","entry":"OrthoCosLoss","repo":"cisiplab/cisip-fire","repo_kind":"listed","path":"functions/loss/orthocos.py","file_url":"https://github.com/cisiplab/cisip-fire/blob/HEAD/functions/loss/orthocos.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"51f777eea1887485"}},{"code_sha256_prefix":"2ea411f078599d51","entry":"OrthoHashLoss","repo":"kamwoh/orthohash","repo_kind":"official","path":"functions/loss/orthohash.py","file_url":"https://github.com/kamwoh/orthohash/blob/HEAD/functions/loss/orthohash.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"2ea411f078599d51"}},{"code_sha256_prefix":"13450b62dcee2e2a","entry":"get_imbalance_mask","repo":"cisiplab/cisip-fire","repo_kind":"listed","path":"functions/loss/orthocos.py","file_url":"https://github.com/cisiplab/cisip-fire/blob/HEAD/functions/loss/orthocos.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"13450b62dcee2e2a"}},{"code_sha256_prefix":"d2b1a5f7c60e27b5","entry":"one_hot","repo":"kamwoh/orthohash","repo_kind":"official","path":"utils/datasets.py","file_url":"https://github.com/kamwoh/orthohash/blob/HEAD/utils/datasets.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":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"d2b1a5f7c60e27b5"}},{"code_sha256_prefix":"bedb4a705f71cf90","entry":"BaseClassificationLoss","repo":"cisiplab/cisip-fire","repo_kind":"listed","path":"functions/loss/orthocos.py","file_url":"https://github.com/cisiplab/cisip-fire/blob/HEAD/functions/loss/orthocos.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"bedb4a705f71cf90"}},{"code_sha256_prefix":"2fe62c1d3f1d5224","entry":"BaseClassificationLoss","repo":"kamwoh/orthohash","repo_kind":"official","path":"functions/loss/orthohash.py","file_url":"https://github.com/kamwoh/orthohash/blob/HEAD/functions/loss/orthohash.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"2fe62c1d3f1d5224"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}