{"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/towards-optimal-feature-shaping-methods-for","title":"Towards Optimal Feature-Shaping Methods for Out-of-Distribution Detection","arxiv_id":"2402.00865","date":"2024-02-01","proceeding":null,"authors":["Qinyu Zhao","Ming Xu","Kartik Gupta","Akshay Asthana","Liang Zheng","Stephen Gould"],"abstract":"Feature shaping refers to a family of methods that exhibit state-of-the-art performance for out-of-distribution (OOD) detection. These approaches manipulate the feature representation, typically from the penultimate layer of a pre-trained deep learning model, so as to better differentiate between in-distribution (ID) and OOD samples. However, existing feature-shaping methods usually employ rules manually designed for specific model architectures and OOD datasets, which consequently limit their generalization ability. To address this gap, we first formulate an abstract optimization framework for studying feature-shaping methods. We then propose a concrete reduction of the framework with a simple piecewise constant shaping function and show that existing feature-shaping methods approximate the optimal solution to the concrete optimization problem. Further, assuming that OOD data is inaccessible, we propose a formulation that yields a closed-form solution for the piecewise constant shaping function, utilizing solely the ID data. Through extensive experiments, we show that the feature-shaping function optimized by our method improves the generalization ability of OOD detection across a large variety of datasets and model architectures.","url_abs":"https://arxiv.org/abs/2402.00865v1","url_pdf":"https://arxiv.org/pdf/2402.00865v1.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":"towards-optimal-feature-shaping-methods-for","repo_url":"https://github.com/qinyu-allen-zhao/optfsood","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"ood-detection","task_name":"Out of Distribution (OOD) Detection"},{"task_slug":"out-of-distribution-detection","task_name":"Out-of-Distribution Detection"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2402.00865","atlas_url":"https://app.syntology.ai/?focus=2402.00865","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.00865"}},"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/qinyu-allen-zhao/optfsood","reach":{"status":"ok"}}],"summary":{"ran_fixture":1,"ran":2,"ran_draft_wrong":2,"unverified":2},"by_repo_kind":{"official":{"samples":7,"ran":5,"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":7,"samples":[{"code_sha256_prefix":"7d8eaf5537f699e4","entry":"np2th","repo":"qinyu-allen-zhao/optfsood","repo_kind":"official","path":"model/mlp_mixer.py","file_url":"https://github.com/qinyu-allen-zhao/optfsood/blob/HEAD/model/mlp_mixer.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":2,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7d8eaf5537f699e4"}},{"code_sha256_prefix":"9346577c5a71350d","entry":"checkpoint_filter_fn","repo":"qinyu-allen-zhao/optfsood","repo_kind":"official","path":"model/vit_cifar.py","file_url":"https://github.com/qinyu-allen-zhao/optfsood/blob/HEAD/model/vit_cifar.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":"9346577c5a71350d"}},{"code_sha256_prefix":"2a80220dabcb742a","entry":"conv1x1","repo":"qinyu-allen-zhao/optfsood","repo_kind":"official","path":"model/resnet.py","file_url":"https://github.com/qinyu-allen-zhao/optfsood/blob/HEAD/model/resnet.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"2a80220dabcb742a"}},{"code_sha256_prefix":"600ff2c45e0de056","entry":"conv3x3","repo":"qinyu-allen-zhao/optfsood","repo_kind":"official","path":"model/resnet.py","file_url":"https://github.com/qinyu-allen-zhao/optfsood/blob/HEAD/model/resnet.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"600ff2c45e0de056"}},{"code_sha256_prefix":"b5dbfbeaf3d26a90","entry":"get_init_weights_vit","repo":"qinyu-allen-zhao/optfsood","repo_kind":"official","path":"model/vit_cifar.py","file_url":"https://github.com/qinyu-allen-zhao/optfsood/blob/HEAD/model/vit_cifar.py","link_basis":"harvester_set","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":"b5dbfbeaf3d26a90"}},{"code_sha256_prefix":"ed04551ca8295bde","entry":"resize_pos_embed","repo":"qinyu-allen-zhao/optfsood","repo_kind":"official","path":"model/vit_cifar.py","file_url":"https://github.com/qinyu-allen-zhao/optfsood/blob/HEAD/model/vit_cifar.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":"ed04551ca8295bde"}},{"code_sha256_prefix":"4f6b58a81890f15c","entry":"shifted_window_attention","repo":"qinyu-allen-zhao/optfsood","repo_kind":"official","path":"model/swin.py","file_url":"https://github.com/qinyu-allen-zhao/optfsood/blob/HEAD/model/swin.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":"4f6b58a81890f15c"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}