{"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/on-the-importance-of-gradients-for-detecting","title":"On the Importance of Gradients for Detecting Distributional Shifts in the Wild","arxiv_id":"2110.00218","date":"2021-10-01","proceeding":"NeurIPS 2021 12","authors":["Rui Huang","Andrew Geng","Yixuan Li"],"abstract":"Detecting out-of-distribution (OOD) data has become a critical component in ensuring the safe deployment of machine learning models in the real world. Existing OOD detection approaches primarily rely on the output or feature space for deriving OOD scores, while largely overlooking information from the gradient space. In this paper, we present GradNorm, a simple and effective approach for detecting OOD inputs by utilizing information extracted from the gradient space. GradNorm directly employs the vector norm of gradients, backpropagated from the KL divergence between the softmax output and a uniform probability distribution. Our key idea is that the magnitude of gradients is higher for in-distribution (ID) data than that for OOD data, making it informative for OOD detection. GradNorm demonstrates superior performance, reducing the average FPR95 by up to 16.33% compared to the previous best method.","url_abs":"https://arxiv.org/abs/2110.00218v2","url_pdf":"https://arxiv.org/pdf/2110.00218v2.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":"on-the-importance-of-gradients-for-detecting","repo_url":"https://github.com/deeplearning-wisc/gradnorm_ood","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"out-of-distribution-detection","task_name":"Out-of-Distribution Detection"}],"methods":[{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-9","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs Places","model":"GradNorm (ResNetv2-101)","rank_in_archive_order":18,"of":25,"metrics":{"FPR95":"60.86"},"uses_additional_data":false},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-8","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs SUN","model":"GradNorm (ResNetv2-101)","rank_in_archive_order":13,"of":22,"metrics":{"FPR95":"46.48"},"uses_additional_data":false},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-10","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs Textures","model":"GradNorm (ResNetv2-101)","rank_in_archive_order":32,"of":34,"metrics":{"FPR95":"61.42"},"uses_additional_data":false},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-3","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs iNaturalist","model":"GradNorm","rank_in_archive_order":27,"of":28,"metrics":{"FPR95":"50.03"},"uses_additional_data":false}],"syntology":{"syntology_url":"https://syntology.ai/paper/2110.00218","atlas_url":"https://app.syntology.ai/?focus=2110.00218","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2110.00218"}},"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/deeplearning-wisc/gradnorm_ood","reach":null}],"summary":{"ran_violates":2,"ran_draft_wrong":2},"by_repo_kind":{"official":{"samples":1,"ran":1,"repositories":1},"community":{"samples":3,"ran":3,"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":"99b3563ebc6734ad","entry":"default","repo":"lucidrains/gradnorm-pytorch","repo_kind":"community","path":"gradnorm_pytorch/gradnorm_pytorch.py","file_url":"https://github.com/lucidrains/gradnorm-pytorch/blob/HEAD/gradnorm_pytorch/gradnorm_pytorch.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"99b3563ebc6734ad"}},{"code_sha256_prefix":"b7c3487f192e31b7","entry":"exists","repo":"lucidrains/gradnorm-pytorch","repo_kind":"community","path":"gradnorm_pytorch/gradnorm_pytorch.py","file_url":"https://github.com/lucidrains/gradnorm-pytorch/blob/HEAD/gradnorm_pytorch/gradnorm_pytorch.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b7c3487f192e31b7"}},{"code_sha256_prefix":"4f7e2211ea4ab0b6","entry":"l1norm","repo":"lucidrains/gradnorm-pytorch","repo_kind":"community","path":"gradnorm_pytorch/gradnorm_pytorch.py","file_url":"https://github.com/lucidrains/gradnorm-pytorch/blob/HEAD/gradnorm_pytorch/gradnorm_pytorch.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4f7e2211ea4ab0b6"}},{"code_sha256_prefix":"ebe2ed60c7172764","entry":"setup_logger","repo":"deeplearning-wisc/gradnorm_ood","repo_kind":"official","path":"utils/log.py","file_url":"https://github.com/deeplearning-wisc/gradnorm_ood/blob/HEAD/utils/log.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ebe2ed60c7172764"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}