{"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/unraveling-batch-normalization-for-realistic","title":"Unraveling Batch Normalization for Realistic Test-Time Adaptation","arxiv_id":"2312.09486","date":"2023-12-15","proceeding":null,"authors":["Zixian Su","Jingwei Guo","Kai Yao","Xi Yang","Qiufeng Wang","Kaizhu Huang"],"abstract":"While recent test-time adaptations exhibit efficacy by adjusting batch normalization to narrow domain disparities, their effectiveness diminishes with realistic mini-batches due to inaccurate target estimation. As previous attempts merely introduce source statistics to mitigate this issue, the fundamental problem of inaccurate target estimation still persists, leaving the intrinsic test-time domain shifts unresolved. This paper delves into the problem of mini-batch degradation. By unraveling batch normalization, we discover that the inexact target statistics largely stem from the substantially reduced class diversity in batch. Drawing upon this insight, we introduce a straightforward tool, Test-time Exponential Moving Average (TEMA), to bridge the class diversity gap between training and testing batches. Importantly, our TEMA adaptively extends the scope of typical methods beyond the current batch to incorporate a diverse set of class information, which in turn boosts an accurate target estimation. Built upon this foundation, we further design a novel layer-wise rectification strategy to consistently promote test-time performance. Our proposed method enjoys a unique advantage as it requires neither training nor tuning parameters, offering a truly hassle-free solution. It significantly enhances model robustness against shifted domains and maintains resilience in diverse real-world scenarios with various batch sizes, achieving state-of-the-art performance on several major benchmarks. Code is available at \\url{https://github.com/kiwi12138/RealisticTTA}.","url_abs":"https://arxiv.org/abs/2312.09486v3","url_pdf":"https://arxiv.org/pdf/2312.09486v3.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":"unraveling-batch-normalization-for-realistic","repo_url":"https://github.com/kiwi12138/realistictta","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"diversity","task_name":"Diversity"},{"task_slug":"test-time-adaptation","task_name":"Test-time Adaptation"}],"methods":[{"method_slug":"batch-normalization","method_name":"Batch Normalization"},{"method_slug":"set","method_name":"SET"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2312.09486","atlas_url":"https://app.syntology.ai/?focus=2312.09486","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2312.09486"}},"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/kiwi12138/realistictta","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":8,"unverified":2},"by_repo_kind":{"official":{"samples":10,"ran":8,"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":"74266460a6b98446","entry":"build_resnet26","repo":"kiwi12138/realistictta","repo_kind":"official","path":"models/resnet26.py","file_url":"https://github.com/kiwi12138/realistictta/blob/HEAD/models/resnet26.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"74266460a6b98446"}},{"code_sha256_prefix":"ecd72bd245fd1a06","entry":"complete_data_dir_path","repo":"kiwi12138/realistictta","repo_kind":"official","path":"conf.py","file_url":"https://github.com/kiwi12138/realistictta/blob/HEAD/conf.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ecd72bd245fd1a06"}},{"code_sha256_prefix":"ae33aa95d68dffd6","entry":"create_file_list","repo":"kiwi12138/realistictta","repo_kind":"official","path":"datasets/imagenet_subsets.py","file_url":"https://github.com/kiwi12138/realistictta/blob/HEAD/datasets/imagenet_subsets.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ae33aa95d68dffd6"}},{"code_sha256_prefix":"8d3dc39f1d44b9c0","entry":"get_augmentation","repo":"kiwi12138/realistictta","repo_kind":"official","path":"augmentations/transforms_adacontrast.py","file_url":"https://github.com/kiwi12138/realistictta/blob/HEAD/augmentations/transforms_adacontrast.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8d3dc39f1d44b9c0"}},{"code_sha256_prefix":"673e36f60eb9d037","entry":"get_augmentation_versions","repo":"kiwi12138/realistictta","repo_kind":"official","path":"augmentations/transforms_adacontrast.py","file_url":"https://github.com/kiwi12138/realistictta/blob/HEAD/augmentations/transforms_adacontrast.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"673e36f60eb9d037"}},{"code_sha256_prefix":"ad7ee34b3774e46a","entry":"get_num_classes","repo":"kiwi12138/realistictta","repo_kind":"official","path":"conf.py","file_url":"https://github.com/kiwi12138/realistictta/blob/HEAD/conf.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ad7ee34b3774e46a"}},{"code_sha256_prefix":"cdb20267e34f8ba5","entry":"scale_to_mean_std","repo":"kiwi12138/realistictta","repo_kind":"official","path":"methods/norm.py","file_url":"https://github.com/kiwi12138/realistictta/blob/HEAD/methods/norm.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cdb20267e34f8ba5"}},{"code_sha256_prefix":"b5803842be7e8357","entry":"split_results_by_domain","repo":"kiwi12138/realistictta","repo_kind":"official","path":"utils.py","file_url":"https://github.com/kiwi12138/realistictta/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b5803842be7e8357"}},{"code_sha256_prefix":"2081ff5a04dad3e5","entry":"create_imagenet_subset","repo":"kiwi12138/realistictta","repo_kind":"official","path":"datasets/imagenet_subsets.py","file_url":"https://github.com/kiwi12138/realistictta/blob/HEAD/datasets/imagenet_subsets.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2081ff5a04dad3e5"}},{"code_sha256_prefix":"cfc577ab97377255","entry":"get_domain_sequence","repo":"kiwi12138/realistictta","repo_kind":"official","path":"conf.py","file_url":"https://github.com/kiwi12138/realistictta/blob/HEAD/conf.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cfc577ab97377255"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}