\documentclass[UTF8]{csoarticle}

\usepackage{booktabs}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{pdfcomment}
\usepackage{colortbl}
\usepackage[table]{xcolor}  % 代替 colortbl，自带表格行着色和颜色混合支持

\newtheorem{theorem}{定理}
\newtheorem{lemma}{引理}
\renewcommand{\proofname}{证明}
% 如果为英文文章，可以使用下面的定义(去除行首的注释符号%)代替上述中文定义
% \newtheorem{theorem}{Theorem}
% \newtheorem{lemma}{Lemma}

\begin{document}

%----------------------------------------------------------
% 1. 文章标头信息
%----------------------------------------------------------

\titleCHN{DBPT：基于双存储的连续测试时间自适应提示微调}
\titleENG{DBPT:Dual-Bank Prompt Tuning for Continual Test-Time Adaptation}
\authorCHN{张敏\affil{1}，吴振宇\affil{1}，纪阳\affil{1}}
\authorENG{ZHANG Min\affil{1}, WU Zhengyu\affil{1}, JI Yang}
\affiliationCHN{
    \affil{1} 北京邮电大学信息与通信工程学院，北京 100876
}
\affiliationENG{
    \affil{1} School of Information and Communication Engineering, Beijing University of Posts and Telecommunications, Beijing 100876
}
\abstractCHN{连续测试时间域自适应（Continual Test-Time Adaptation, CTTA）旨在使预训练模型能够持续适应不断变化的测试域。动态变化的场景通常会导致错误积累和灾难性遗忘，现有的CTTA方法主要依赖单一的知识存储机制，难以同时利用域级和类别级的语义信息。针对这一问题，本文提出一种基于双Bank存储策略的两阶段Prompt自适应方法，通过同时建模域级与类级特异性特征，使冻结的预训练模型在原始特征空间上面对动态场景能够获得更稳健的分类能力。该方法维护了两个Bank：域Bank与类Bank，分别存储历史域的统计信息与各类别的高质量样本原型，并设计两阶段更新策略：阶段一用域Bank生成加权Prompt并进行域级优化，将目标域拉近源域空间；阶段二以第一阶段的Promt为起点实施类级细粒度更新并结合源域原型约束进行类别对齐。实验结果表明，本文方法在多种基准场景下均显著优于现有CTTA方法。}
\abstractENG{Continual Test-Time Adaptation (CTTA) aims to enable pre-trained models to continuously adapt to evolving test domains without access to source data. However, dynamic environments often lead to error accumulation and catastrophic forgetting during online adaptation. Existing CTTA methods mainly rely on a single knowledge storage mechanism, which limits the ability to simultaneously exploit domain-level and class-level semantic information.

To address this limitation, a two-stage prompt-based adaptation framework with a dual-bank memory strategy is introduced, explicitly modeling both domain-specific and class-specific characteristics. By operating on the original frozen feature space of pre-trained models, the proposed approach enhances robustness under continuously changing test conditions. Two complementary memory banks are maintained: a Domain Bank, which stores historical domain statistics, and a Class Bank, which preserves high-quality class prototypes. Based on these banks, a two-stage update strategy is designed. In the first stage, weighted prompts are generated by leveraging the Domain Bank to perform domain-level adaptation, aligning the target domain toward the source feature distribution. In the second stage, starting from the adapted prompts obtained in the first stage, fine-grained class-level prompt optimization is conducted under source-domain prototype constraints to achieve precise category alignment.

Extensive experiments on multiple CTTA benchmarks demonstrate that the proposed method consistently outperforms existing state-of-the-art CTTA approaches, validating its effectiveness and robustness in dynamic test-time adaptation scenarios.}
\keywordCHN{连续测试时间域自适应，Vision Transformer，提示学习，双Bank存储；两阶段更新}
\keywordENG{Continual Test-Time Adaptation, Vision Transformer, Prompt Learning, Dual-Bank Storage }
\cateidCHN{TP391.41}

\authorIntroduction{张敏（2001-），女，研究生，主要研究方向：迁移学习，邮箱：zhangblahblah@bupt.edu.cn。通信作者：吴振宇（1986-），男，副教授，主要研究方向：工业人工智能，邮箱：shower0512@bupt.edu.cn。}
\fund{***基金(00000000)，***基金(00000000)}

\maketitle


%----------------------------------------------------------
% 2. 正文内容
%----------------------------------------------------------
\section{引言}
\label{sec:intro}
随着深度学习技术的快速发展，预训练模型取得显著成功。但在实际场景中，自适应环境往往受到诸多约束。例如，在某些医疗场景中，由于隐私问题，源域样本在推理阶段通常不可用。因此，测试时自适应（Test-Time Adaptation, TTA）\cite{bib1}成为重要研究方向，其旨在不访问源域样本的情况下，使预训练模型适应无标签目标数据。现实系统通常运行于非平稳动态环境中，目标分布随时间不断变化，如自动驾驶中的天气、光照和路况变化。这种动态偏移对传统域适应方法带来挑战。为此，持续测试时自适应（CTTA）\cite{bib2}旨在在无源域数据情况下持续适应变化环境。

在CTTA中，随分布变化\cite{bib2,bib3}，伪标签\cite{bib4}逐渐失准并引发误差累积；同时模型在长期适应过程中容易遗忘已有知识。因此，CTTA面临两大问题：误差累积与灾难性遗忘。在CoTTA \cite{bib2}中，通过数据增强平均来减少误差累积，并通过随机重置来缓解灾难性遗忘。EcoTTA \cite{bib6}采用自蒸馏正则化，使得输出不会显著偏离原始模型，从而避免灾难性遗忘。RMT \cite{bib7}利用源域数据来减少误差累积并防止灾难性遗忘。RoTTA \cite{bib8}和NOTE \cite{bib9}维护一个记忆库以存储全局信息，缓解误差累积问题。

进一步地，现实场景往往呈现更加动态的模式，一个域可能重复出现。DPCore \cite{bib10} 将此称为持续动态变化（Continual Dynamic Change, CDC）。例如山路驾驶时会在晴天与隧道间切换时，此时模型不仅遗忘源域，也可能遗忘早期目标域。DPCore \cite{bib10}、PAINT \cite{bib11} 和 HisTPT \cite{bib12} 通过维护域提示库保存历史知识。然而仅依赖域级信息\cite{bib13}难以保留类别特定知识，持续域对齐还可能导致类间结构退化甚至类别塌陷。

为应对上述挑战，我们提出了一种双库提示调优（Dual-Bank Prompt Tuning, DBPT）策略。该方法同时维护域级与类别级知识库，先进行域级对齐，再进行类别级优化。主要贡献如下：
\begin{itemize}
    \item 双库存储策略：Domain Bank保存不同域统计与最优提示，Class Bank维护类别原型，联合建模域共性与类别特性。
    \item 自适应双库融合与两阶段更新：先利用Class Bank计算域权重完成域优化，再进行类别细粒度更新，源域原型可用时进行进一步对齐。
    \item 实验评估：在CIFAR-100-C与ImageNet-C上进行实验验证，并与Tent \cite{bib1}、CoTTA \cite{bib2}、DPCore \cite{bib10}等比较，结果表明DBPT在性能上更具优势。
\end{itemize}

\section{预备知识与问题定义}
在本节中，我们将介绍CTTA问题的研究范式、Vision Transformer（ViT），以及记忆库的常规范式。
\subsection{CTTA}
测试时自适应（Test-Time Adaptation, TTA）旨在使预训练的源模型在测试阶段适应未见过的目标域。不同于假设目标域静态不变的标准TTA，持续测试时自适应（Continual Test-Time Adaptation, CTTA）进一步考虑目标域以序列形式出现（记为 \( D_1D_2D_3\cdots \)），要求模型在持续适应新域的同时，避免对历史域知识的灾难性遗忘。

我们将问题形式化如下：设源训练数据集为 \( \mathcal{D}_{\text{src}} = \{( \boldsymbol{x}_i^s, y_i^s )\}_{i=1}^{N_s} \)，其中 \( \boldsymbol{x}_i^s \in \mathbb{R}^{H \times W \times C} \) 表示源域图像，\( y_i^s \in \{1, 2, \ldots, K\} \) 为对应的类别标签，\( K \) 为类别总数。对于第 \( t \) 个测试域 \( D_t \)，模型只能以顺序方式访问无标签测试数据 \( D_t = \{( \boldsymbol{x}_j^t )\}_{j=1}^{N_t} \)。CTTA的目标是在时间步 \( t \) 学习得到一个自适应模型 \( f_\theta^t \)，使得：

\begin{equation}
\mathcal{L}_{\text{adapt}}^t = \mathbb{E}_{(\boldsymbol{x}_j^t) \in D_t} \left[ \mathcal{L} \left( f_\theta^t(\boldsymbol{x}_j^t), \hat{y}_j^t \right) \right] \to \min
\end{equation}

其中，\( \hat{y}_j^t \) 为测试样本 \( \boldsymbol{x}_j^t \) 的伪标签（通常由当前模型生成），\( \mathcal{L} \) 表示自适应损失函数（例如用于一致性正则化的交叉熵损失）。

CTTA的核心约束在于：由于内存限制，模型只能存储有限的历史信息，并且必须在在线场景下进行适应，不能重新访问源数据集。

遵循文献 \cite{bib1}中的标准假设，我们假设批次 \( B_t \) 中的所有样本均来自同一目标域，尽管域身份未知。按照DPCore\cite{bib10} 在CDC场景下的设置，我们采用参数为 \( \delta \) 的Dirichlet分布来模拟动态环境，其中 \( \delta = 1 \) 用于在结构化变化与完全随机变化之间取得平衡。

\subsection{Vision Transformer (ViT) 和 Prompt 调优}
Vision Transformer（ViT）将自然语言处理（NLP）中的Transformer架构引入视觉任务，用于建模图像中的全局空间依赖关系。其核心优势在于强大的全局依赖建模能力，在大规模数据预训练后可取得优异的视觉识别性能。然而，对整个ViT进行完全微调以适应测试域不仅计算开销较大，而且容易对含噪测试数据产生过拟合。因此，在CTTA场景中，更高效的自适应方法（如提示调优\cite{bib14,bib15}）成为优选方案\cite{bib16,bib17,bib18}。

给定输入图像 \( \boldsymbol{x} \in \mathbb{R}^{H \times W \times C} \)，将其划分为 \( N \) 个不重叠的图像块 \( \boldsymbol{p}_1, \boldsymbol{p}_2, \ldots, \boldsymbol{p}_N \)（其中 \( N = \lfloor H/P \rfloor \times \lfloor W/P \rfloor \)，\( P \) 为patch大小）。提示调优是一种面向大规模预训练模型的高效自适应策略，其核心思想是冻结预训练主干网络，仅优化可学习的提示token，使下游任务与预训练目标对齐。一组可学习的提示token序列 \( \boldsymbol{P} = [\boldsymbol{p}_1^*, \boldsymbol{p}_2^*, \ldots, \boldsymbol{p}_M^*] \in \mathbb{R}^{M \times D} \)（其中 \( M \) 为提示token数量）被插入到ViT嵌入序列中（可以置于图像patch嵌入之前的前缀位置，或插入到编码器层之间）。增强后的ViT输入序列为：
\begin{equation}
\boldsymbol{z}_0' = \left[ \boldsymbol{e}_{\text{cls}}; \boldsymbol{P}; \boldsymbol{e}_1 + \boldsymbol{\pi}_1; \ldots; \boldsymbol{e}_N + \boldsymbol{\pi}_N \right]
\end{equation}

在自适应过程中，仅优化提示token \( \boldsymbol{P} \)，而ViT主干网络（包括图像patch嵌入、位置嵌入和编码器层）保持冻结。

提示调优的目标是通过更新提示token最小化自适应损失（例如熵损失与一致性损失的组合），从而提升模型在目标域上的性能。其关键优势在于参数量较小，在仅更新少量参数的情况下保证自适应效果，同时维持较快的推理速度，契合CTTA场景中实时自适应的核心需求 \cite{bib19}。

\subsection{记忆库}
记忆库（记为“Bank”）是持续自适应与测试时自适应中的核心组件。它通过存储历史信息（如特征、统计量和模型参数），可缓解灾难性遗忘并提升自适应稳定性。其设计主要围绕两个关键维度：存储内容与更新策略。在TTA/CTTA场景中，常见的存储内容包括样本特征、批次特征、批统计信息以及提示参数；典型更新策略包括FIFO、基于置信度排序、混合更新以及滑动平均。

现有基于记忆库的CTTA方法大多采用单库设计：要么存储域级统计信息（如 DPCore \cite{bib10}, PAINT \cite{bib11}），要么存储类别级原型（如 CoTTA \cite{bib2}, RMT \cite{bib7}, TDA \cite{bib20}）。仅以域为中心的记忆库缺乏维护细粒度类别知识的能力，在域对齐过程中易破坏类内结构；仅以类别为中心的记忆库则难以捕捉全局域统计特征，无法准确适应不同目标域。上述局限启发我们提出双库提示调优策略——通过融合Domain Bank与Class Bank，联合建模域级共性与类别级特性，从而克服单库设计的内在缺陷。

\section{方法}

本节介绍双库提示调优（Dual-Bank Prompt Tuning, DBPT）算法。如图1所示，DBPT主要由三个组成部分构成：视觉提示调优、双库记忆机制以及两阶段自适应策略。通过保留历史访问的域级与类别级知识，这三个组件使得模型在不同域与不同类别样本间进行更准确地推理。

\subsection{双Bank结构设计}
为了在CTTA场景下保留已学习的域级与类别级知识，我们维护一个Domain Bank和一个Class Bank。

\subsubsection{Domain Bank}
Domain Bank用于存储域级统计信息及对应的提示向量。对于每个域 \( d \)，我们维护一个三元组 \( D_d = (\mu_d, \sigma_d, \mathbf{p}_d) \)，其中 \( \mu_d \) 和 \( \sigma_d \) 分别表示该域特征的均值与标准差，\( \mathbf{p}_d \) 表示对应的域级提示向量。该结构初始化为空，并随着新域的到来持续扩展。每当输入一个新批次时，我们首先在无提示条件下计算当前批次的特征统计量，然后与Domain Bank中各条目的统计信息进行匹配，得到权重 \( {w}_i \)。随后，根据Domain Bank中加权后的提示，确定域级提示更新的初始点，如式 (3) 所示。

\begin{equation}
\label{eq:weighted_prob}
p_\omega = \sum \omega_i p_i
\end{equation}

我们通过判定准则 \( \text{ID} \Leftrightarrow L_{\text{new}} < \rho L_{\text{raw}} \) 来判断当前批次是否来自新域。其中，\( L_{\text{raw}} \) 表示未使用加权提示时的批次损失，\( L_{\text{new}} \) 表示使用加权提示后的损失，\( \rho \) 为阈值（设为0.8）。若新损失相较原始损失的相对下降超过 \( (1-\rho) \)，则该批次被判定为ID批次。完成域级更新后，采用指数滑动平均更新Bank中对应的特征统计量；若为OOD批次，则在域更新完成后，将其特征统计量及提示作为新域加入Domain Bank。

\begin{figure*}[!htbp] 
    \centering
    % 调整width数值即可改变大小，例如：
    \includegraphics[width=0.9\textwidth]{DBPT_structure.png}  % 占文本宽度90%（更大）
    % \includegraphics[width=0.7\textwidth]{DBPT_structure.png}  % 占文本宽度70%（更小）
    \caption{DBPT框架示意图。整体框架主要分为两个阶段：上半部分对应阶段一，下半部分对应阶段二。样本首先通过Domain Bank进行域级更新；置信度满足条件的样本将进入阶段二，基于Class Bank中的样本进行类别级更新。两个Bank的更新方式如图所示。模型的详细描述参见方法章节。}
    \label{fig:DBPT_structure}
\end{figure*}

\subsubsection{Class Bank}
Class Bank用于存储类别级语义信息。具体而言，对于每个类别 \( c \)，我们维护一个样本集合和一个类别原型。样本集合初始化为空，类别原型初始化为分类头权重。样本集合存储样本特征及其置信度：\( C_c = \{(f_i, \text{conf}_i)\}_{i=1}^{K_c} \)，其中 \( f_i \) 表示样本特征，\( \text{conf}_i \) 表示样本置信度，\( K_c \) 表示该类别允许存储的最大样本数。在对当前批次中的高置信度样本进行类别级微调时，将检索其预测类别对应的原型并进行拉近约束。

Class Bank的样本集合更新遵循FIFO原则。每当有新特征加入队列时，若队列达到容量上限，则自动移除最早的样本。每个类别的原型通过将样本集合中的所有特征求均值，并进行L2归一化得到。该原型始终表示该类别高置信度样本的平均方向，用于指导样本的类别级微调。



\begin{algorithm}[htbp]
\caption{Two-Stage Adaptation}
\label{alg:two_stage}
\begin{algorithmic}[1]
\REQUIRE data $x$, model, coreset, prototypes, threshold
\ENSURE outputs
\STATE \textbf{Initialization}: coreset $\leftarrow \emptyset$, prototypes $\leftarrow \emptyset$, tokens $\leftarrow \emptyset$
\vspace{0.5em}
% \COMMENT{Stage 1: Domain-Level Adaptation}
\STATE \text{// Stage 1: Domain-Level Adaptation}
\STATE $\text{is\_ID}, \text{weighted\_prompts} \leftarrow \_eval\_coreset(x)$
\IF{$\text{is\_ID}$}
    \STATE $\text{model.prompts} \leftarrow \text{weighted\_prompts}$
    \STATE $\text{outputs}, \text{loss} \leftarrow \text{forward\_and\_adapt}(x, \text{model}, \text{optimizer})$
    \STATE $\_update\_coreset(\text{weights}, \text{batch\_mean}, \text{batch\_std})$
\ELSE
    \STATE $\text{reset\_model\_to\_initial\_state}()$
    \STATE $\text{outputs}, \text{loss} \leftarrow \text{forward\_and\_adapt}(x, \text{model}, \text{optimizer})$
    \STATE $\text{coreset.append}([\text{batch\_mean}, \text{batch\_std}, \text{model.prompts}])$
\ENDIF
\vspace{0.5em}
\STATE \text// {Stage 2: Class-Level Fine-Grained Update}
\STATE $\text{features} \leftarrow \text{model.forward\_features}(x)$
\STATE $\text{match\_classes}, \text{confidences} \leftarrow \text{get\_class\_confi}(\text{probs})$
\FOR{each sample $i$ in batch}
    \IF{$\text{confidences}[i] < \text{threshold}$}
        \STATE \textbf{continue}
    \ENDIF
    \STATE $\text{model.prompts} \leftarrow \text{domain\_prompt}$
    \STATE $P_i \leftarrow \text{prototypes}[\text{pred\_classes}[i]]$
    
    \STATE $\text{output}_i, \text{loss}_i \leftarrow \text{forward\_and\_adapt\_class}(x[i], P_i)$
    \STATE $\text{features\_for\_update.append}(\text{features}[i])$
\ENDFOR
\STATE $\text{update\_prototypes\_with\_queue}()$
\RETURN $\text{outputs}$
\end{algorithmic}
\end{algorithm}

\subsection{两阶段更新策略}
在提示调优策略下，由于ViT模型本身的参数（特征提取器与分类头）保持不变，不同域样本在不同提示作用下得到的特征仍位于同一特征空间（坐标系）中，分类边界也保持不变。不同提示的作用在于改变样本特征在该坐标系中的分布，即对当前样本特征进行空间平移。由Domain Bank得到的加权提示，为当前批次样本提供了一个更接近源域分布的更新起点，如算法1所示。

在完成域对齐后，所有样本将更加接近源域空间。在这一相对统一的特征空间中，对不同域样本进行类别级微调更为合理。因此，我们设计了两阶段提示更新策略：
\begin{itemize}
    \item \textbf{Domain-Level Update}: 第一阶段旨在缩小当前批次样本与源域空间之间的距离。其损失函数如公式4所示，其中 $\boldsymbol{\mu}_b$ 和 $\boldsymbol{\sigma}_b$ 表示当前批次特征的均值与标准差向量，$\boldsymbol{\mu}_s$ 和 $\boldsymbol{\sigma}_s$ 表示源域特征的均值与标准差向量，通过约束二者距离，将当前批次样本拉近至源域空间。
    \item \textbf{Class-Level Update}: 第二阶段以前一阶段得到的提示为起点。对于高置信度样本，在Class Bank中检索其预测类别对应的样本，计算类别原型，并以距离约束作为类别级更新损失（公式5，其中 $\boldsymbol{z}_i$ 表示当前样本特征，$P_{C_i}$ 表示目标类别对应的原型特征），以缩小样本与类别原型之间的距离，使目标域样本进一步定位到源域空间中的对应类别中心。
\end{itemize}

\begin{equation}
\label{eq:domain_loss}  % 标签，后文引用用 \eqref{eq:domain_loss}
\mathcal{L}_{\text{domain}} = \lambda \|\sigma_b - \sigma_b\|_2 + \|\mu_b - \mu_s\|_2
\end{equation}
\begin{equation}
\label{eq:proto_loss}  % 标签，后文引用用 \eqref{eq:proto_loss}
\mathcal{L}_{\text{proto}} = 2\left(1 - \cos(\boldsymbol{z}_i, P_{C_i})\right)
\end{equation}



\subsection{源域原型辅助}
若可获得源域类别原型，则在第一阶段的域级对齐中加入源域原型距离约束。通过对权重参数 \( \lambda \) 进行调节，使当前批次在逐步接近源域空间的同时兼顾类别级约束（如公式6），从而抑制类别漂移。此外，在第二阶段对高置信度样本进行细粒度提示微调时，可以将Class Bank中的类别原型直接替换为源域原型，使微调过程更加精确。

\begin{equation}
\label{eq:final_loss}
L_{\text{final}} = L_{\text{domain}} + \sum_{i=1}^n L_{\text{proto}}
\end{equation}

\subsection{理论分析}\label{subsec:theoretical_analysis}

从信息论的角度来看，双 Bank 架构能够提供更多的信息。设 Domain Bank 提供的信息量为 $I_d$，Class Bank 提供的信息量为 $I_c$，则双 Bank 架构的总信息量为：
\begin{equation}
I_{\text{total}} = I_d + I_c - I_{\text{overlap}}    
\end{equation}

其中，$I_{\text{overlap}}$ 表示两个 Bank 之间的信息重叠量。由于域级信息与类别级信息具有互补性，$I_{\text{overlap}}$ 相对较小，因此双 Bank 架构能够提供更为有效的信息。

Domain Bank 负责建模域级的宏观分布偏移，Class Bank 则维护细粒度语义信息。二者在不同尺度上提供先验知识，因此需要进行两级融合。对于源域类别原型而言，其提供了偏向“源语义”的正则化约束，以降低方差。通过调节 $\beta$，可以在“紧密跟随目标域”与“保持源语义”之间实现动态平衡，并为第二阶段的精细化优化提供更可靠的几何锚点。


\section{实验}

\subsection{实验设置}
数据集：我们在以下数据集上进行了实验：  
(1) ImageNet-C：包含15种不同类型的域偏移，例如噪声、模糊、天气变化等。  
(2) CIFAR-100-C：CIFAR-100的扰动版本，包含15种不同的域偏移类型。

基线方法：我们将所提出的方法与以下基线方法进行了比较：  
(1) TENT\cite{bib1}：一种基于熵最小化的测试时自适应方法。  
(2) CoTTA\cite{bib2}：一种采用教师-学生框架的持续测试时自适应方法。  
(3) DPCore\cite{bib10}：一种基于prompt coreset的域自适应方法。  
(4) VDP\cite{bib16}：一种基于视觉prompt调优的方法。  
(5) SAR\cite{bib3}：一种采用sharpness-aware和可靠熵最小化的方法。  
(6) ViDA\cite{bib21}：一种使用高层和低层域适配器来管理域特定知识与共享知识的方法。  
(7) RoTTA\cite{bib8}  
(8) EcoTTA\cite{bib6} 以及其他方法。  

在我们的实验中，我们遵循 DPCore\cite{bib10} 中定义的标准协议来评估所提出的方法。  
具体而言，我们使用相同的训练/测试划分比例和评估指标（\textit{e.g.}, Top-1 Accuracy）以确保一致性。  
包括 Tent\cite{bib1}、CoTTA\cite{bib2}、VDP\cite{bib16}、SAR\cite{bib3}、EcoTTA\cite{bib6} 和 ViDA\cite{bib21} 在内的基线方法结果均引用自 DPCore\cite{bib10}，因为这些方法在其工作中已在相同实验条件下进行了充分验证。  
我们重新实现了方法 DPCore\cite{bib10} 以在我们的代码框架中验证其性能，结果与原始报告基本一致。我们的实验结果是8次独立运行结果的平均值。

实验场景：  
\begin{itemize}
    \item CSC 场景；  
    \item CDC 场景（使用参数为 $\delta=1$ 的 Dirichlet 分布来模拟动态环境）。
\end{itemize}

Other Settings: 我们的设置与 DPCore\cite{bib10} 保持一致。对于所有模型，我们使用 vit\_base\_patch16\_224 作为骨干网络，并采用 Error（平均类别错误率）作为评估指标。我们使用 AdamW 优化器，学习率设为 0.01，并选择 $L=8$ 作为 prompt token 的数量，$\rho=0.8$ 作为阈值。


\subsection{实验结果}
在 ImageNet-to-ImageNet-C 的 CDC 场景下（如表 1 所示），当不可获得源域原型时，我们的方法的错误率比 DPCore\cite{bib10} 降低了 2.4\%。这充分表明，类 Bank 为原有的域级 Bank 补充了类别信息，从而提高了分类准确性。同时，当可获得源域原型时，错误率进一步降低了 3.9\%，这进一步说明，更精确的类别信息能够发挥更强的补充作用。

\begin{table}[htbp]
\centering
\footnotesize  % 缩小字体，紧凑显示内容
\setlength{\tabcolsep}{2pt}  % 压缩列间距（默认6pt，设为2pt进一步收紧）
\caption{分类错误率 (\%) 在 ImageNet-to-ImageNet-C (severity = 5) 的 CDC 场景下}\label{tab1}
% 列格式修改：最后一列从c（居中）改为l（左对齐），竖线分组同步调整
\begin{tabular}{l|ccc|ccc|ccc|ccc|ccc|l}
\toprule
Algorithm & gauss & shot & impulse & defocus & glass & motion & zoom & snow & frost & fog & bright & contrast & elastic & pixelate & jpeg & average \\
\midrule
Source & 53 & 51.8 & 52.1 & 68.5 & 78.8 & 58.5 & 63.3 & 49.9 & 54.2 & 57.7 & 26.4 & 91.4 & 57.5 & 38 & 36.2 & 55.8 \\
Tent & 54.1 & 53.2 & 52.9 & 66.7 & 74.6 & 56.6 & 61.2 & 49.2 & 52.3 & 57.5 & 32.1 & 90.4 & 56.1 & 37.7 & 37.1 & 55.4 \\
CoTTA & 52.4 & 52.2 & 51.1 & 68.4 & 76.3 & 57.9 & 62.1 & 48.7 & 53.1 & 55.1 & 26.1 & 88.9 & 57.1 & 37.6 & 38.2 & 55 \\
VDP & 53.1 & 53.3 & 51.5 & 62.4 & 73.1 & 53.4 & 60.1 & 43.5 & 54.3 & 58.2 & 25.1 & 82.2 & 56.6 & 35.7 & 36.3 & 53.3 \\
SAR & 47 & 46.1 & 46.1 & 56.1 & 66.4 & 49.9 & 55.1 & 41.1 & 44.8 & 50.9 & 23.6 & 65.3 & 54.2 & 32.9 & 31.4 & 47.4 \\
EcoTTA & 48.9 & 47.4 & 49.3 & 59.2 & 71.2 & 54.1 & 59.8 & 46.2 & 44.3 & 57.2 & 24 & 84.1 & 55.2 & 37.2 & 35.3 & 51.6 \\
ViDA & 48.8 & 49.2 & 47.3 & 56.6 & 71.6 & 55.3 & 59.6 & 41.2 & 49.4 & 60.5 & 27.1 & 83.9 & 57.9 & 34.6 & 34.4 & 51.8 \\
dpcore & 46.47 & 44.99 & 45.72 & 52.47 & 53.62 & 47.05 & 48.36 & 39.02 & 38.64 & 36.61 & 25.46 & 48.85 & 43.34 & 32.57 & 32.88 & 42.41 \\
\midrule
DBPT & 43.74 & 42.36 & 42.45 & 50.34 & 49.53 & 45.35 & 46.04 & 36.95 & 36.7 & 34.72 & 22.92 & 47.27 & 40.15 & 30.89 & 30.71 & \textbf{40.01(-2.4)} \\
DBPT\_source & 41.50 & 39.94 & 40.02 & 45.90 & 44.84 & 41.55 & 42.28 & 32.81 & 33.05 & 29.31 & 20.96 & 40.47 & 34.53 & 27.02 & 28.04 & \textbf{36.15(-3.86)} \\
\bottomrule
\end{tabular}
\end{table}

在 ImageNet-to-ImageNet-C 的 CSC 场景下（如表 2 所示），当不可获得源域原型时，我们的方法的错误率降低了 0.4\%。在 CDC 场景中，同一域可能以不同的频率和持续时间多次出现，需要频繁切换域 Bank，而类 Bank 提供了更稳定的类别信息。然而，在域变化规律性的 CSC 场景中，域 Bank 已能够有效适应（每个域仅出现一次），因此类 Bank 的辅助作用相对有限。当可获得源域原型时，错误率降低了 3.3\%，这同样表明，更精确的类别信息能够发挥更强的补充作用。


\begin{table*}[!htbp]
\centering
\footnotesize  % 缩小字体，紧凑显示内容
\setlength{\tabcolsep}{2pt}  % 压缩列间距（默认6pt，设为2pt进一步收紧）
\caption{分类错误率(\%) 在 ImageNet-to-ImageNet-C (severity = 5) 的 CSC 场景下}\label{tab2}
% 列格式修改：最后一列从c（居中）改为l（左对齐），竖线分组同步调整
\begin{tabular}{l|ccc|ccc|ccc|ccc|ccc|l}
\toprule
Algorithm & gauss & shot & impulse & defocus & glass & motion & zoom & snow & frost & fog & bright & contrast & elastic & pixelate & jpeg & average \\
\midrule
Source & 53 & 51.8 & 52.1 & 68.5 & 78.8 & 58.5 & 63.3 & 49.9 & 54.2 & 57.7 & 26.4 & 91.4 & 57.5 & 38 & 36.2 & 55.8 \\ 
Tent & 52.2 & 48.9 & 49.2 & 65.8 & 73 & 54.5 & 58.4 & 44 & 47.7 & 50.3 & 23.9 & 72.8 & 55.7 & 34.4 & 33.9 & 51 \\
CoTTA & 52.9 & 51.6 & 51.4 & 68.3 & 78.1 & 57.1 & 62 & 48.2 & 52.7 & 55.3 & 25.9 & 90 & 56.4 & 36.4 & 35.2 & 54.8 \\
VDP & 52.7 & 51.6 & 50.1 & 58.1 & 70.2 & 56.1 & 58.1 & 42.1 & 46.1 & 45.8 & 23.6 & 70.4 & 54.9 & 34.5 & 36.1 & 50 \\
SAR & 45.8 & 45.9 & 47.7 & 52.3 & 63.7 & 46.2 & 50.9 & 40.3 & 42.4 & 41.8 & 24.4 & 53.4 & 53.6 & 38.4 & 36.6 & 45.6 \\ 
EcoTTA & 48.1 & 45.6 & 46.3 & 56.5 & 67.1 & 50.4 & 57.1 & 41.3 & 44.5 & 43.8 & 24.1 & 71.6 & 54.8 & 34.1 & 34.8 & 48 \\
ViDA & 47.7 & 42.5 & 42.9 & 52.2 & 56.9 & 45.5 & 48.9 & 38.9 & 42.7 & 40.7 & 24.3 & 52.8 & 49.1 & 33.5 & 33.1 & 43.4 \\
dpcore & 41.01 & 39.69 & 38.9 & 46.57 & 48.91 & 42.93 & 42.32 & 32.08 & 31.21 & 29.95 & 21.04 & 39.26 & 37.76 & 28.13 & 27.77 & 36.5 \\ 
\midrule
DBPT & 41.14 & 39.46 & 38.59 & 45.52 & 47.61 & 41.81 & 42.15 & 32.74 & 30.97 & 28.53 & 21.17 & 39.88 & 36.26 & 28.39 & 28.30 & \textbf{36.17(-0.4)} \\
DBPT\_source & 39.35 & 36.67 & 36.04 & 42.43 & 42.42 & 36.08 & 35.07 & 28.44 & 29.19 & 25.08 & 19.98 & 35.09 & 35.19 & 25.12 & 26.69 & \textbf{32.86(-3.31)} \\
\bottomrule
\end{tabular}
\end{table*}

在 CIFAR100-to-CIFAR100C 的 CSC 场景下（如表 3 所示），当不可获得源域原型时，我们的方法将错误率降低了 0.5\%。在 CDC 场景下（如表 4 所示），当不可获得源域原型时，错误率降低了 0.6\%。CIFAR100C 是一个相对简单的数据集，类别数量较少且类间区分难度较低，因此域 Bank 已能够较好地处理域偏移，类 Bank 所带来的额外收益相对有限。相比之下，ImageNet 具有更多类别和更高的判别难度，因此类 Bank 提供的类别信息更具价值。


\begin{table*}[!htbp]
\centering
\footnotesize  % 缩小字体，紧凑显示内容
\setlength{\tabcolsep}{2pt}  % 压缩列间距（默认6pt，设为2pt进一步收紧）
\caption{分类错误率 (\%) 在 CIFAR100-to-CIFAR100C 的 CSC 场景下}\label{tab3}
\begin{tabular}{l|ccc|ccc|ccc|ccc|ccc|l}
\toprule
Algorithm & Gauss & Shot & Impulse & Defocus & Glass & Motion & Zoom & Snow & Frost & Fog & Bright & Contrast & Elastic & Pixel & JPEG & Mean \\
\midrule
Source & 55.0 & 51.5 & 26.9 & 24.0 & 60.5 & 29.0 & 21.4 & 21.1 & 25.0 & 35.2 & 11.8 & 34.8 & 43.2 & 56.0 & 35.9 & 35.4 \\
Tent  & 53.0 & 47.0 & 24.6 & 22.3 & 58.5 & 26.5 & 19.0 & 21.0 & 23.0 & 30.1 & 11.8 & 25.2 & 39.0 & 47.1 & 33.3 & 32.1 \\
CoTTA  & 55.0 & 51.3 & 25.8 & 24.1 & 59.2 & 28.9 & 21.4 & 21.0 & 24.7 & 34.9 & 11.7 & 31.7 & 40.4 & 55.7 & 35.6 & 34.8 \\
VDP  & 54.8 & 51.2 & 25.6 & 24.2 & 59.1 & 28.8 & 21.2 & 20.5 & 23.3 & 33.8 & 7.5 & 11.7 & 32.0 & 51.7 & 35.2 & 32.0 \\
ViDA  & 50.1 & 40.7 & 22.0 & 21.2 & 45.2 & 21.6 & 16.5 & 17.9 & 16.6 & 25.6 & 11.5 & 29.0 & 29.6 & 34.7 & 27.1 & 27.3 \\
\rowcolor{yellow!80}
\pdfcomment{对模型在CIFAR100-to-CIFAR100C 的 CSC 和 CDC 场景下的实验结果进行勘误。我们发现该数据明显不符合常理，经排查，是由早期的错误计算代码的结果被误抄至论文中所致，此代码导致数据在原有范围内发生大幅震荡。现已修正为正确代码逻辑的实验结果。由于imagenet-c与cifar-c处于独立的实验项目，此番修正不影响模型在其他数据集上的结果。补充实验由于在imagenet-c上进行，所以也未受到影响。算法整体逻辑和结论并未受到影响}
DPCore  & 48.9 & 39.8 & 20.5 & 20.5 & 43.5 & 21.2 & 16.0 & 17.6 & 15.6 & 21.6 & 9.6 & 12.9 & 27.7 & 33.4 & 26.1 & 25.0 \\
\midrule
\rowcolor{yellow!80} DBPT & 48.1 & 39.5 & 19.8 & 20.0 & 43.1 & 21.0 & 15.8 & 17.8 & 15.2 & 20.9 & 9.5 & 12.5 & 27.6 & 32.3 & 25.0 & \textbf{24.5(-0.5)} \\
\rowcolor{yellow!80} DBPT\_source & 46.0 & 38.7 & 19.2 & 19.5 & 41.9 & 20.6 & 15.2 & 17.0 & 15.0 & 20.2 & 9.3 & 11.8 & 27.1 & 31.5 & 23.5 & \textbf{23.8} \\
\bottomrule
\end{tabular}
\end{table*}

\begin{table*}[!htbp]
\centering
\footnotesize  % 缩小字体，紧凑显示内容
\setlength{\tabcolsep}{2pt}  % 压缩列间距（默认6pt，设为2pt进一步收紧）
\caption{分类错误率 (\%) 在 CIFAR100-to-CIFAR100C 的 CDC 场景下}\label{tab4}
\begin{tabular}{l|ccc|ccc|ccc|ccc|ccc|l}
\toprule
Algorithm & Gauss & Shot & Impulse & Defocus & Glass & Motion & Zoom & Snow & Frost & Fog & Bright & Contrast & Elastic & Pixel & JPEG & Mean \\
\midrule
Source & 55.0 & 51.5 & 26.9 & 24.0 & 60.5 & 29.0 & 21.4 & 21.1 & 25.0 & 35.2 & 11.8 & 34.8 & 43.2 & 56.0 & 35.9 & 35.4 \\
Tent & 53.5 & 46.5 & 26.2 & 25.8 & 61.0 & 28.1 & 23.5 & 21.7 & 22.6 & 30.9 & 11.0 & 24.4 & 41.3 & 49.1 & 36.7 & 33.5 \\
CoTTA & 53.3 & 51.9 & 27.1 & 26.3 & 60.5 & 29.2 & 21.3 & 22.5 & 23.5 & 35.6 & 13.7 & 33.7 & 41.6 & 59.1 & 39.4 & 35.9 \\
VDP  & 56.6 & 53.5 & 31.8 & 29.1 & 63.9 & 33.9 & 23.5 & 25.7 & 29.9 & 38.5 & 12.1 & 15.5 & 34.0 & 53.8 & 39.6 & 36.1 \\
ViDA  & 50.1 & 42.1 & 23.9 & 23.3 & 48.1 & 23.7 & 19.5 & 18.7 & 18.5 & 29.6 & 11.6 & 36.1 & 32.6 & 37.1 & 32.8 & 29.8 \\
\rowcolor{yellow!80} 
\pdfcomment{对模型在CIFAR100-to-CIFAR100C 的 CSC 和 CDC 场景下的实验结果进行勘误。我们发现该数据明显不符合常理，经排查，是由早期的错误计算代码的结果被误抄至论文中所致，此代码导致数据在原有范围内发生大幅震荡。现已修正为正确代码逻辑的实验结果。由于imagenet-c与cifar-c处于独立的实验项目，此番修正不影响模型在其他数据集上的结果。补充实验由于在imagenet-c上进行，所以也未受到影响。算法整体逻辑和结论并未受到影响}
DPCore & 54.0 & 42.5 & 23.5 & 22.8 & 45.3 & 21.4 & 18.5 & 21.2 & 16.7 & 23.2 & 10.0 & 15.1 & 35.7 & 34.6 & 26.0 & 27.4 \\
\midrule
\rowcolor{yellow!80} DBPT & 52.4 & 41.7 & 23.0 & 22.6 & 43.6 & 20.8 & 18.2 & 20.8 & 16.6 & 22.8 & 10.2 & 14.9 & 35.1 & 33.8 & 25.6 & \textbf{26.8(-0.6)} \\
\rowcolor{yellow!80} DBPT\_source & 51.7 & 40.5 & 22.9 & 22.5 & 42.8 & 20.1 & 17.4 & 20.2 & 15.9 & 22.1 & 9.8 & 14.1 & 34.5 & 33.4 & 25.2 & \textbf{26.2} \\
\bottomrule
\end{tabular}
\end{table*}

\subsection{补充实验}
在消融实验（表 \ref{tab5}）中可以看到，我们提出的双 Bank 结构和两阶段策略均是有效的。对于类 Bank 队列大小的选择，图 \ref{fig:bank_sample_count} 表明：当样本数量超过 5 个时，准确率下降幅度非常缓慢。综合考虑存储开销与性能之间的平衡，我们将类别队列大小设为 5。在置信度阈值的实验（图 \ref{fig:stage_two_threshold}）中，我们发现较低的置信度阈值会使部分低质量样本参与更新，导致错误率反而上升；而当置信度阈值过高时，进入第二阶段更新的样本数量过少，性能提升不明显。最终我们选择 0.8 作为置信度阈值。

\begin{table}[h]
  \centering  % 关键：添加居中命令
  \caption{消融实验}\label{tab5}
  % 可选：缩小字体让表格更紧凑（单栏适配）
  \footnotesize
  \begin{tabular}{@{}l|lll|ll@{}}
    \toprule
    Strategy & two\_bank  & two\_stage & source\_proto & CSC & CDC\\ 
    \midrule
    DPCore    & -   & -  & - & 0 & 0 \\ 
    exp1      & $\checkmark$   & $\checkmark$  & - & -0.4 & -2.4 \\ 
    exp2      & $\checkmark$  & -  & $\checkmark$ & -3.1 & -4.6  \\ 
    exp3      & $\checkmark$   & $\checkmark$  & $\checkmark$ & -3.7 & -6.2  \\ 
    \bottomrule
  \end{tabular}
  \footnotetext{DPCore: The ablation study takes DPCore\cite{bib10} as the baseline.}
\end{table}

\begin{figure}[htbp]
    \centering
    % 第一张图
    \includegraphics[width=0.7\linewidth]{bank_sample_count.png} 
    \caption{Bank Sample Count Result (CDC Setting)} 
    \label{fig:bank_sample_count} 
    
    \vspace{0.5cm}  % 图间间距，可调整（如0.3cm/0.6cm）
    % 第二张图
    \includegraphics[width=0.7\linewidth]{stage_two_threshold.png} 
    \caption{Stage Two Threshold Result (CDC Setting)}
    \label{fig:stage_two_threshold} 
    
    \vspace{0.5cm}
    % 第三张图
    \includegraphics[width=0.9\linewidth]{distance_inter_class.png} 
    \caption{Inter-class Distance Result (CDC Setting)}
    \label{fig:distance_inter_class} 
    
\end{figure}

\section{总结与未来工作}

我们提出了一种基于 ViT 的双 Bank 架构两阶段持续测试时域适应方法，实现了域级与类别级知识的协同存储与利用。基于双 Bank 设计的特点，我们进一步设计了两阶段更新策略：第一阶段侧重于域级对齐，第二阶段在第一阶段结果的基础上进行类别级精细化微调。在多个基准数据集上的大量实验验证了所提方法的有效性，表明其在持续域适应任务中具有优越性能。

局限：当前方法仍存在一定局限性。首先，无法对一个批次中的所有样本都进行类别级微调。其次，在相对简单的场景中，类别 Bank 的补充能力较为有限。

未来工作：未来可以探索度量不同域之间的类别偏移以及单个类别的偏移程度，从而进一步提升类别级微调的有效性。

\section*{致谢}

谨向参与研究以来导师的悉心指导和实验室师兄师姐提供的帮助表示由衷的感谢。

\clearpage

%----------------------------------------------------------
% 3. 参考文献
%----------------------------------------------------------

\begin{thebibliography}{21}
    \bibitem{bib1} Wang D, Shelhamer E, Liu S, et al. Tent: Fully test-time adaptation by entropy minimization[J]. arXiv preprint arXiv:2006.10726, 2020.
    \bibitem{bib2} Wang Q, Fink O, Van Gool L, et al. Continual test-time domain adaptation[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2022: 7201-7211.
    \bibitem{bib3} Niu S, Wu J, Zhang Y, et al. Towards stable test-time adaptation in dynamic wild world[J]. arXiv preprint arXiv:2302.12400, 2023.
    \bibitem{bib4} Lee D H. Pseudo-label: The simple and efficient semi-supervised learning method for deep neural networks[C]//Workshop on challenges in representation learning, ICML. 2013, 3(2): 896.
    \bibitem{bib5} Yang X, Chen X, Li M, et al. A versatile framework for continual test-time domain adaptation: Balancing discriminability and generalizability[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2024: 23731-23740.
    \bibitem{bib6} Song J, Lee J, Kweon I S, et al. Ecotta: Memory-efficient continual test-time adaptation via self-distilled regularization[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2023: 11920-11929.
    \bibitem{bib7} Döbler M, Marsden R A, Yang B. Robust mean teacher for continual and gradual test-time adaptation[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2023: 7704-7714.
    \bibitem{bib8} Yuan L, Xie B, Li S. Robust test-time adaptation in dynamic scenarios[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2023: 15922-15932.
    \bibitem{bib9} Gong T, Jeong J, Kim T, et al. Note: Robust continual test-time adaptation against temporal correlation[J]. Advances in Neural Information Processing Systems, 2022, 35: 27253-27266.
    \bibitem{bib10} Zhang Y, Mehra A, Niu S, et al. DPCore: Dynamic Prompt Coreset for Continual Test-Time Adaptation[C]//Forty-second International Conference on Machine Learning.
    \bibitem{bib11} Cui C, Zhen Y, Gong S, et al. Dynamic prompt allocation and tuning for continual test-time adaptation[J]. arXiv preprint arXiv:2412.09308, 2024.
    \bibitem{bib12} Zhang J, Huang J, Zhang X, et al. Historical test-time prompt tuning for vision foundation models[J]. Advances in Neural Information Processing Systems, 2024, 37: 12872-12896.
    \bibitem{bib13} Zhou J, Zhu C, Cui Z, et al. Class-aware Domain Knowledge Fusion and Fission for Continual Test-Time Adaptation[J]. arXiv preprint arXiv:2510.12150, 2025.
    \bibitem{bib14} Sun J, Ibrahim M, Hall M, et al. Vpa: Fully test-time visual prompt adaptation[C]//Proceedings of the 31st ACM International Conference on Multimedia. 2023: 5796-5806.
    \bibitem{bib15} Ge C, Huang R, Xie M, et al. Domain adaptation via prompt learning[J]. IEEE Transactions on Neural Networks and Learning Systems, 2023.
    \bibitem{bib16} Gan Y, Bai Y, Lou Y, et al. Decorate the newcomers: Visual domain prompt for continual test time adaptation[C]//Proceedings of the AAAI conference on artificial intelligence. 2023, 37(6): 7595-7603.
    \bibitem{bib17} Zhang Y, Mehra A, Hamm J. OT-VP: Optimal transport-guided visual prompting for test-time adaptation[C]//2025 IEEE/CVF Winter Conference on Applications of Computer Vision (WACV). IEEE, 2025: 1122-1132.
    \bibitem{bib18} Niu S, Miao C, Chen G, et al. Test-time model adaptation with only forward passes[J]. arXiv preprint arXiv:2404.01650, 2024.
    \bibitem{bib19} Gao Y, Shi X, Zhu Y, et al. Visual prompt tuning for test-time domain adaptation[J]. arXiv preprint arXiv:2210.04831, 2022.
    \bibitem{bib20} Karmanov A, Guan D, Lu S, et al. Efficient test-time adaptation of vision-language models[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2024: 14162-14171.
    \bibitem{bib21} Liu J, Yang S, Jia P, et al. Vida: Homeostatic visual domain adapter for continual test time adaptation[J]. arXiv preprint arXiv:2306.04344, 2023.

\end{thebibliography}

\end{document}
