上述目标的最终梯度更新形式如下:其中 受启发于 SAM [4] 通过一阶泰勒展开近似求解得到,具体细节可参见本论文原文与代码。至此,本文的总体优化目标为:此外,为了防止极端条件下上述方案仍可能失败的情况,进一步引入了一个模型复原策略:通过移动监测模型是否出现退化崩溃,决定在必要时刻对模型更新参数进行原始值恢复。
▲ 表1. SAR 与现有方法在 ImageNet-C 的 15 种损坏类型混合场景下性能对比,对应动态场景 (a);以及和现有方法的效率对比
▲ 表2. SAR 与现有方法在 ImageNet-C 上单样本适应场景中的性能对比,对应动态场景 (b)
▲ 表3. SAR 与现有方法在 ImageNet-C 上在线非均衡类别分布偏移场景中性能对比,对应动态场景(c)
消融实验与梯度裁剪方法的对比:梯度裁剪避免大梯度影响模型更新(甚至导致坍塌)的一种简单且直接的方法。此处与梯度裁剪的两个变种(即:by value or by norm)进行对比。如下图所示,梯度裁剪对于梯度裁剪阈值 δ 的选取很敏感,较小的 δ 与模型不更新的结果相当,较大的 δ 又难以避免模型坍塌。相反,SAR 不需要繁杂的超参数筛选过程且性能显著优于梯度裁剪。
[1] Yu Sun, Xiaolong Wang, Zhuang Liu, John Miller, Alexei Efros, and Moritz Hardt. Test-time training with self-supervision for generalization under distribution shifts. In International Conference on Machine Learning, pp. 9229–9248, 2020.
[2] Dequan Wang, Evan Shelhamer, Shaoteng Liu, Bruno Olshausen, and Trevor Darrell. Tent: Fully test-time adaptation by entropy minimization. In International Conference on Learning Representations, 2021.[3] Shuaicheng Niu, Jiaxiang Wu, Yifan Zhang, Yaofo Chen, Shijian Zheng, Peilin Zhao, and Mingkui Tan. Efficient test-time model adaptation without forgetting. In International Conference on Machine Learning, pp. 16888–16905, 2022.[4] Pierre Foret, Ariel Kleiner, Hossein Mobahi, and Behnam Neyshabur. Sharpness-aware minimization for efficiently improving generalization. In International Conference on Learning Representations, 2021.[5] Tong Wu, Feiran Jia, Xiangyu Qi, Jiachen T. Wang, Vikash Sehwag, Saeed Mahloujifar, and Prateek Mittal. Uncovering adversarial risks of test-time adaptation. arXiv preprint arXiv:2301.12576, 2023.