{"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/distribution-alignment-for-fully-test-time","title":"Distribution Alignment for Fully Test-Time Adaptation with Dynamic Online Data Streams","arxiv_id":"2407.12128","date":"2024-07-16","proceeding":null,"authors":["Ziqiang Wang","Zhixiang Chi","Yanan Wu","Li Gu","Zhi Liu","Konstantinos Plataniotis","Yang Wang"],"abstract":"Given a model trained on source data, Test-Time Adaptation (TTA) enables adaptation and inference in test data streams with domain shifts from the source. Current methods predominantly optimize the model for each incoming test data batch using self-training loss. While these methods yield commendable results in ideal test data streams, where batches are independently and identically sampled from the target distribution, they falter under more practical test data streams that are not independent and identically distributed (non-i.i.d.). The data batches in a non-i.i.d. stream display prominent label shifts relative to each other. It leads to conflicting optimization objectives among batches during the TTA process. Given the inherent risks of adapting the source model to unpredictable test-time distributions, we reverse the adaptation process and propose a novel Distribution Alignment loss for TTA. This loss guides the distributions of test-time features back towards the source distributions, which ensures compatibility with the well-trained source model and eliminates the pitfalls associated with conflicting optimization objectives. Moreover, we devise a domain shift detection mechanism to extend the success of our proposed TTA method in the continual domain shift scenarios. Our extensive experiments validate the logic and efficacy of our method. On six benchmark datasets, we surpass existing methods in non-i.i.d. scenarios and maintain competitive performance under the ideal i.i.d. assumption.","url_abs":"https://arxiv.org/abs/2407.12128v1","url_pdf":"https://arxiv.org/pdf/2407.12128v1.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":"distribution-alignment-for-fully-test-time","repo_url":"https://github.com/WZq975/DA-TTA","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"test-time-adaptation","task_name":"Test-time Adaptation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2407.12128","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2407.12128"}},"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/WZq975/DA-TTA","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":8,"ran_fixture":1,"ran_draft_wrong":1,"unverified":7},"by_repo_kind":{"official":{"samples":17,"ran":10,"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":"00900164f55d3e7c","entry":"complete_data_dir_path","repo":"WZq975/DA-TTA","repo_kind":"official","path":"conf.py","file_url":"https://github.com/WZq975/DA-TTA/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":"00900164f55d3e7c"}},{"code_sha256_prefix":"ae33aa95d68dffd6","entry":"create_file_list","repo":"WZq975/DA-TTA","repo_kind":"official","path":"datasets/imagenet_subsets.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/datasets/imagenet_subsets.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":"ae33aa95d68dffd6"}},{"code_sha256_prefix":"473a24407468b75e","entry":"entropy_energy","repo":"WZq975/DA-TTA","repo_kind":"official","path":"methods/lame.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/methods/lame.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":"473a24407468b75e"}},{"code_sha256_prefix":"ad7ee34b3774e46a","entry":"get_num_classes","repo":"WZq975/DA-TTA","repo_kind":"official","path":"conf.py","file_url":"https://github.com/WZq975/DA-TTA/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":"ad7ee34b3774e46a"}},{"code_sha256_prefix":"3078648c75e3e1e3","entry":"softmax_entropy","repo":"WZq975/DA-TTA","repo_kind":"official","path":"methods/datta.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/methods/datta.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3078648c75e3e1e3"}},{"code_sha256_prefix":"f0cf18b3022925f3","entry":"softmax_entropy_cifar","repo":"WZq975/DA-TTA","repo_kind":"official","path":"methods/cotta.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/methods/cotta.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":"f0cf18b3022925f3"}},{"code_sha256_prefix":"e2785d59d7e26ba2","entry":"softmax_entropy_imagenet","repo":"WZq975/DA-TTA","repo_kind":"official","path":"methods/cotta.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/methods/cotta.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":"e2785d59d7e26ba2"}},{"code_sha256_prefix":"155e6f06ad63c237","entry":"stat_loss","repo":"WZq975/DA-TTA","repo_kind":"official","path":"methods/datta.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/methods/datta.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":"155e6f06ad63c237"}},{"code_sha256_prefix":"eaa0b5d0d74c3ab3","entry":"tta","repo":"WZq975/DA-TTA","repo_kind":"official","path":"methods/memo.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/methods/memo.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":"eaa0b5d0d74c3ab3"}},{"code_sha256_prefix":"a77d556c0aea19c1","entry":"update_ema_variables","repo":"WZq975/DA-TTA","repo_kind":"official","path":"methods/cotta.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/methods/cotta.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a77d556c0aea19c1"}},{"code_sha256_prefix":"fae69c4390cf3b2c","entry":"batch_norm","repo":"WZq975/DA-TTA","repo_kind":"official","path":"methods/datta.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/methods/datta.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":"fae69c4390cf3b2c"}},{"code_sha256_prefix":"04cb16a031d4e8b2","entry":"create_imagenet_subset","repo":"WZq975/DA-TTA","repo_kind":"official","path":"datasets/imagenet_subsets.py","file_url":"https://github.com/WZq975/DA-TTA/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":"04cb16a031d4e8b2"}},{"code_sha256_prefix":"cfc577ab97377255","entry":"get_domain_sequence","repo":"WZq975/DA-TTA","repo_kind":"official","path":"conf.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/conf.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":"cfc577ab97377255"}},{"code_sha256_prefix":"d2597d43cbd2fbca","entry":"laplacian_optimization","repo":"WZq975/DA-TTA","repo_kind":"official","path":"methods/lame.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/methods/lame.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":"d2597d43cbd2fbca"}},{"code_sha256_prefix":"8a657c2641647a46","entry":"marginal_entropy","repo":"WZq975/DA-TTA","repo_kind":"official","path":"methods/memo.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/methods/memo.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":"8a657c2641647a46"}},{"code_sha256_prefix":"7b9d88d29b50aca6","entry":"softmax_entropy","repo":"WZq975/DA-TTA","repo_kind":"official","path":"methods/eata.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/methods/eata.py","link_basis":"plan_row","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":"7b9d88d29b50aca6"}},{"code_sha256_prefix":"182d3657a9eebb0d","entry":"update_model_probs","repo":"WZq975/DA-TTA","repo_kind":"official","path":"methods/eata.py","file_url":"https://github.com/WZq975/DA-TTA/blob/HEAD/methods/eata.py","link_basis":"plan_row","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":"182d3657a9eebb0d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}