Variational Model Perturbation for Source-Free Domain Adaptation
Abstract
We aim for source-free domain adaptation, where the task is to deploy a model pre-trained on source domains to target domains.
The challenges stem from the distribution shift from the source to the target domain, coupled with the unavailability of any source data and labeled target data for optimization.
Rather than ﬁne-tuning the model by updating the parameters, we propose to perturb the source model to achieve adaptation to target domains.
We introduce perturbations into the model parameters by variational Bayesian inference in a probabilistic framework.
By doing so, we can effectively adapt the model to the target domain while largely preserving the discriminative ability.
Importantly, we demonstrate the theoretical connection to learning Bayesian neural networks, which proves the generalizability of the perturbed model to target domains.
To enable more efﬁcient optimization, we further employ a parameter sharing strategy, which substantially reduces the learnable parameters compared to a fully Bayesian neural network.
Our model perturbation provides a new probabilistic way for domain adaptation which enables efﬁcient adaptation to target domains while maximally preserving knowledge in source models.
Experiments on several source-free benchmarks under three different evaluation settings verify the effectiveness of the proposed variational model perturbation for source-free domain adaptation.
Introduction
A well-trained neural network can achieve satisfactory performance on in-distribution tasks.
However, in real applications, a common situation is that the training set and the test set are from different distributions.
In this case, the performance of the models usually degrades signiﬁcantly due to domain shifts.
Domain adaptation (DA) [1, 2, 3, 4] is proposed to solve this problem by transferring knowledge from the labeled source domain (the training set) to the unlabeled target domain (the test set).
It is assumed that source data are still available when adapting to target data.
In this paper, we focus on the more challenging scenario where source data are not accessible, which is known as source-free domain adaptation (SFDA) [5, 6].
SFDA promises much wider ranges of applications than the vanilla domain adaptation in that it can circumvent the problem of not disclosing source data in order to protect the privacy of individuals or the intellectual property of commercial entities.
To deal with domain shift, two popular techniques in the literature to adapt the SFDA model to the target domain are ﬁne-tuning (updating the whole parameters) and modulating (tuning the batch normalization layers and freeze all the other parameters).
The former focuses on the difference of domains, while the latter focuses on the relevance of domains.
For ﬁne-tuning methods, e.g.,
SHOT [7] and NRC [8], the parameters of the entire model are further updated by designing optimization objectives.
For example, SHOT [7] calibrates the model predictions by information maximization and pseudo-labeled self-supervision, while NRC [8] exploits the nearest neighbor relationship between samples.
Though being empirically successful, both model ﬁne-tuning and batch normalization modulation suffer from drawbacks.
Fine-tuning may cause some problems.
First, the model will deviate from the source data, leading to performance degradation on the source domain, similar to catastrophic forgetting in continual learning [9, 10, 11, 12].
We care about the performance on the source domain since in the more generalized SFDA scenario [13] we do not necessarily have the target domain ID available, and therefore we would not know when to deploy the source model.
Second, ﬁne-tuning could result in a model being biased to a speciﬁc target domain (overﬁtting), thus reducing the generalization of the model [14, 15, 16].
Third, since there are no regularizations from the labeled source data, e.g., cross entropy loss, errors may accumulate and the parameters of the model may be distorted, leading to low performance in Continual Online SFDA [17].
Batch normalization modulation approaches [18, 19, 20] keep weights of all convolutional and fullyconnected (FC) layers frozen, and only modulate the statistics in the batch normalization layers [21] to adapt to target data.
However, they tend to be less ﬂexible and would not continuously adapt to target data with large domain shifts.
In addition, those are all deterministic approaches which suffer from lack of generalizability [22, 23, 24].
In this paper, we propose variational model perturbations, which ﬁxes the existing weights and slightly perturbs them to encode the uncertainties according to the domain shifts.
We learn to perturb model parameters to achieve domain adaptation by variational inference.
By variational perturbations, we introduce uncertainties into the model.
As a result, we perturb a deterministic network into a Bayesian neural network (BNN), allowing the model to generalize to relevant domains.
We demonstrate that by perturbing the model in a variational manner, we are equivalent to learning a special BNN with a ﬁxed mean and a learnable variance.
To achieve more efﬁcient perturbation, we further adopt a parameter sharing strategy, which signiﬁcantly reduces the learnable parameters.
This enables more efﬁcient adaptation in contrast to learning a full BNN.
It is worth noting that the perturbation is naturally regularized due to the variational inference formulation, which prevents the perturbed weights from being distorted during the continuous unsupervised learning.
Our approach is easy to implement, offers a plug-and-play module to adapt model parameters and works seamlessly with different optimization objectives.
We conduct extensive experiments on ﬁve datasets with three different evaluation settings.
The results consistently demonstrate the effectiveness of variational model perturbation for source-free domain adaptation.
Methodology
We start from the vanilla unsupervised domain adaptation, based on which we formally introduce the setting for source-free domain adaptation.
For the vanilla unsupervised domain adaptation setting, we are given a source domain D s = { ( x si , y si ) | x si ∈ X s , y si ∈ Y s } n s i =1 with n s labeled data and a target domain D t = { x tj | x tj ∈ X t } n t j =1 with n t unlabelled data under the condition that p ( X s ) (cid:54) = p ( X t ) where p ( X s ) and p ( X t ) are the source and target data distributions.
The source and target domains share the same label space, i.e., Y s = Y t .
The task is to learn a model f : X t → Y t that could predict the target labels.
In the source-free domain adaptation setting, we are only given the unlabeled target domain data D t = { x tj } n t j =1 and the model trained on the source domain parameterized by w s .
Model Perturbation with Uncertainty From the probabilistic perspective, we deﬁne a model p ( w s | D s ) to be trained on the source domain D s .
Then, the model parameters w s can be optimized by maximum likelihood estimation under the i.i.d.
assumption:
[Equation]
Usually we could optimize Eq.
(1) through mini-batch based stochastic gradient descent [25] and the optimum of w s is a point estimate of the model parameter.
Having a model pre-trained in Eq.
(1) on a source domain, we would like to deploy it on different target domains.
However, usually the performance of the source model degrades signiﬁcantly on the target domains due to the domain shift.
Therefore, we propose to perturb the model parameters based on the point estimate w s in order to make it generalizable to the target domain while maximally maintain the discriminative ability of the source model.
Denote the perturbed weights as w t , which is obtained by a simple perturbation operation as follows:
[Equation]
where ∆ w is the perturbation for w s .
It is worth noting that we only perturb the weights of the convolutional and FC layers in the network and we update the running mean and running variance in the batch normalization layers through moving average.
In this paper, we formulate the perturbation as a variational inference problem in a probabilistic framework.
Given the target domain D t , we compute the posterior distribution of the perturbations by
Bayesian inference, i.e., p (∆ w | D t ) .
However, directly computing the expectations of the posterior distribution is intractable, since it is equivalent to computing expectations of an uncountably inﬁnite set of neural networks [23, 26].
Therefore, as a more realistic alternative, we resort to computing the posterior distributions through variational inference.
Speciﬁcally, assume the perturbations are drawn from a zero-mean distribution,
i.e., ∆ w ∼
N (0 , σ 2 I ) , where σ is the learnable standard deviation.
Then, our task reduces to solving the optimization problem such that the variational posterior q (∆ w | 0 , σ ) can approach the true posterior p (∆ w | D t ) .
We minimize the Kullback-Leibler (KL) divergence between them as follows:
[Equation]
where the ﬁrst term in Eq.
(3) is the KL divergence between the posterior and the prior, and the second term is the expectation likelihood.
The objective function of our method is Eq.
For the expectation likelihood term, it has different implementations and we will discuss it later.
The speciﬁc forms of the objective function under different implementations are included in supplementary material.
Choosing zero as the mean of ∆ w is because we want to avoid the perturbed model deviating much from the source model so that it can adapt to more general settings, i.e. Generalized SFDA [13] and
Continual Online SFDA [17].
In this way, the weights of the perturbed model will vary around the weights of the source model while being generalizable due to the uncertainty induced by non-zero variance.
In essence, we expand the effective coverage of the source model to the target domain.
Connection to Learning a Bayesian Neural Network It has been proven that introducing uncertainty into weights can improve generalizability of neural networks [23, 24].
Actually, under mild conditions, our method is equivalently learning a BNN.
We demonstrate this as follows.
Assume that we would like to learn a neural network by variational Bayesian inference, where we place a prior p ( w t ) over the weight.
We design the variational posterior as q ( w t | w s , σ ) .
Here we assume the mean w s to be a constant which is the point estimate of the model parameters, and the variance σ 2 to be a learnable variable.
We minimize the KL divergence between the variational posterior q ( w t | w s , σ ) and the true posterior p ( w t | D t ) :
[Equation]
As we deﬁne w t =∆ w + w s , the posterior w t ∼ q ( w t | w s , σ 2 ) is transformed from ∆ w ∼ q (∆ w | 0 , σ 2 ) .
By adopting the technique of change of variables to Eq.
(5), we arrive at:
[Equation]
Therefore, minimizing the KL divergence between q ( w t | w s , σ ) and p ( w t | D t ) is equivalent to minimizing the KL divergence between q (∆ w | 0 , σ ) and p (∆ w | D t ) .
Notably, in BNN, the prior is usually set to be noninformative normal Gaussian distribution [22, 23, 27].
Here we just assume we adopt the same noninformative normal Gaussian prior, i.e., p ( w t )=
p (∆ w ) .
For practical optimization, since the prior only serves as a regularizer in the KL divergence term while our goal is to infer the posteriors, the two inferred posteriors do not necessarily have the same variance.
Even if the prior distributions are different, the conclusion that variational model perturbation is equivalent to learning a BNN still holds.
Variational Posterior of Perturbations Following [23], we assume that the variational posterior distribution is a diagonal Gaussian distribution.
Then we can obtain a sample of the perturbations ∆ w by sampling the unit Gaussian and scaling it by the standard deviation σ .
To ensure that σ is non-negative, in practical implementations σ is not calculated and updated directly.
Speciﬁcally, σ is calculated as σ = (cid:112) exp ( ρ ) , where ρ is the de facto variational posterior parameter which is the logarithm of the variance.
Thus, a sample from the perturbed w t can be represented as:
[Equation]
where (cid:15) ∼ N (0 , I ) and ◦ denotes element-wise multiplication.
Prior of Perturbations Previous works have shown that the selection of different priors affects the generalization performance of the model [28, 22, 29].
Considering that weights of each layer have different variations, it may be sub-optimal to use a uniform prior for the whole network.
Therefore, we propose to specify different priors for perturbations of each layer according to the statistical properties within the pre-trained model.
Speciﬁcally, each convolutional layer contains multiple convolutional kernels.
Previous research [28] has found that weights in the same convolutional kernel have strong correlations, while different convolutional kernels do not, even if they are in the same layer.
In view of this, we propose an adaptive prior , which computes the standard deviation of each convolutional kernel in the pre-trained model as the prior of the perturbations of the whole convolutional kernel.
Then, the prior shared by the whole convolutional kernel is as follows:
[Equation]
where p (∆ w li ) represents the prior distribution for perturbations of the i -th convolution kernel in l -th convolutional layer, and Var is the variance of the convolutional kernel in the pre-trained model w s .
λ is a scale coefﬁcient.
We experimentally observed that λ
=1 . 0 can achieve satisfactory performance.
Likelihood Function
In general, variational model perturbation is independent of the likelihood function.
In SFDA, the target data are unlabeled, the likelihood function can be implemented by optimization with respect to unsupervised losses.
For example, we can minimize entropy loss [18] to encourage the model predictions to be close to one-hot encodings.
In addition, Liang et al. [7] highlight that ideal predictions should have enough category diversity, we can achieve this by maximizing the mean of the entropy of predictions in a mini-batch.
All these objective functions can be well integrated within our framework.
We report the results of our method under different implementations of the likelihood in the experimental section.
Parameter Sharing Strategy Since the parameters in the same convolutional kernel have strong correlations [28], it is a natural choice to adopt a parameter sharing strategy for the convolutional layers so that we can further reduce the learnable parameters, i.e., all the weights in the convolutional kernel share the same perturbations.
Thus, the number of learnable parameters for each convolutional layer is equal to the number of output channels.
By doing so, we can largely reduce learnable parameters without signiﬁcantly degrading performance.
Through the parameter sharing strategy, we deconstruct the training process of SFDA into a static invariant part and a dynamic varying part : we can train a model with millions of parameters ( static part ) in the source domain, and then adapt it to different target domains by learning a small number of perturbation parameters ( varying part ), which avoids training the parameters of the whole model every time, reduces the storage space and makes the process of domain adaptation more ﬂexible.
Related Works
Unsupervised Domain Adaptation. Unsupervised domain adaptation [30, 31, 32, 33] aims at transferring knowledge from the source domain to the unlabeled target domain in order to perform
[Table]
This paper
[Table]
× as well on the target domain.
Most methods minimize the expected error of the model on the target domain by reducing the domain shifts.
For example, methods based on adversarial generative networks [34, 1, 35] learn domain-indistinguishable features in an adversarial manner.
Statistical matching methods [36, 37, 38, 39] try to mitigate domain shifts by aligning the ﬁrst- or second-order statistics between domains.
Source-Free Domain Adaptation. Unsupervised domain adaption assumes that source data is available when adapting to target domains, which would not always hold in real-world applications due to issues of intellectual property, individual privacy, decentralisation, etc.
Therefore, Source-Free
Domain Adaptation (SFDA) is proposed to solve this problem [5, 6, 7, 8, 40, 41].
In the setting of SFDA, only the pre-trained model in the source domain and the unlabeled target data are provided.
Kundu et al. [6] align the source and target domains using generative models.
Ishii and Sugiyama [41] reduce domain shifts by aligning the statistics stored in the batch normalization layers.
From an information-theoretic perspective, Liang et al.
[7] proposes SHOT to ﬁne-tune the source model using target data by imposing entropy minimisation and diversity maximisation for predictions.
In addition,
SHOT employs self-supervised learning using pseudo-labels.
Yang et al.
[8] exploit the intrinsic neighborhood structure to encourage label consistency among target data.
Huang et al.
[40] maintain the consistency of features between the historical model and adapted model through contrastive learning.
Online Source-Free Domain Adaptation. SFDA methods [7, 6, 8, 40] assume all target domain data are available during training, and they also optimize dedicated objective functions through multiple iterations.
To be applicable to scenarios such as autonomous driving and real time object tracking online SFDA, also known as test-time adaptation, has been explored.
For example, AdaBN [19] and Test-time BN [20] improve the performance of the model in the target domain by recalculating the Batch Normalization (BN) statistics in the test period instead of using ﬁxed BN statistics from the pre-trained model.
Tent [18] modulates the parameters in the BN layers through entropy minimization to adapt the test data in real time.
For stable and effective adaptation, Tent freezes all the parameters except the BN layers.
Test-Time-Training [42] introduces additional auxiliary tasks to improve test-time performance.
Cotta [17] adopts weight-averaging and augmentation-averaging to calibrate pseudo-labels to avoid error accumulation during continual test-time adaptation, then they use these reliable pseudo-labels for self-supervised regularization.
By contrast, our model perturbation freezes all weights except the batch normalization parameters in the source model, which avoids error accumulation and knowledge forgetting.
We provide a comparison between the proposed model perturbation and related methods in Table 1.
Most existing approaches are developed in a deterministic manner, without exploring the uncertainty.
Differently, in this work we address source-free domain adaption in a probabilistic framework by modelling weight uncertainty.
Bayesian Neural Networks. Our work is also closely related to Bayesian neural networks.
They combine neural networks with Bayesian inference, which explain the uncertainties from the model and provides the distributions over the weights and outputs.
Various techniques have been explored to learn Bayesian neural networks including variational inference [44, 26], probabilistic backpropagation [45], Hamiltonian Monte Carlo [46] and the Laplace approximation [27].
Our variational model perturbation provides an alternative way of implementing Bayesian inference for neural networks.
Compared to previous implementations, our method is plug-and-play and more ﬂexible.
It provides an efﬁcient way to adapt a deterministic source model to a target domain by transforming into a probabilistic one while avoiding re-training a full Bayesian neural network.
Experiments 4.1 Datasets and Settings
Datasets.
We report our experiments on ﬁve datasets.
The Ofﬁce [47] dataset includes 3 domains.
All the images are categorized into 31 classes.
Ofﬁce-Home [48] consists of 4 domains.
Each domain contains 65 different classes.
CIFAR10-C , CIFAR100-C [49] and ImageNet-C [49] includedifferent types of corruptions imposed on the original CIFAR10, CIFAR100 and ImageNet datasets, respectively.
Each corruption type contains 5 different corruption severities.
Each severity has 10, images in CIFAR10-C/CIFAR100-C and 50,000 images in ImageNet-C, respectively.
Evaluation Settings.
We test our method on three source-free domain adaptation settings.
For a clearer elaboration of the experimental details, we clarify SFDA consists of three phases, namely, source pre-training, target adaptation and testing.
Ofﬂine SFDA [6, 5]: In the target adaptation phase, we can access data of the entire target domain and optimize the objective functions with multiple iterations.
Generalized SFDA [13]: we split the source data into 80% and 20% parts.
In the source pre-training phase, we use the labeled 80% part to pre-train the source model.
In the target adaptation phase, we use all the unlabeled target data to adapt the model.
In the testing phase, we predict the remaining 20% source data and all target data.
We compute the harmonic mean of the source and target accuracies: Harmonic = 2 ∗ Acc S ∗ Acc T Acc S + Acc T .
Continual Online SFDA [17]: the target domain phase and the testing phase are carried out simultaneously.
At each iteration, we can only access data in one batch and data in the previous iteration cannot be accessed again.
We carry out this experiment in a more challenging setting where data of different domains are encountered continually.
The detailed training processes of our method under the three settings are in suplementary material.
4.2 Implementation Details
The objective function in Eq.
3 includes the KL divergence loss and the expectation likelihood loss.
In the three settings, we adopt different implementations of the expectation likelihood loss.
For Ofﬂine SFDA and Generalized SFDA, we employ the information loss and self-supervised loss as in SHOT [7] to optimize the expected likelihood loss.
For a fair comparison, we use ResNet-50 as the backbone just as the previous methods [7, 1, 13, 40].
In the source-pretraining phase, this backbone is trained on the source domain to obtain the source pre-trained model.
As for the optimizer, following [7], we employ Stochastic Gradient Descent with weight decay 1e-3 and momentum 0.9.
As for the learning rate, we set 2e-3 for the backbone model and 2e-2 for the bottleneck layer newly added in SHOT.
In addition, β is a hyper-parameter which balances the importance of information loss and self-supervision loss in SHOT.
Since the parameters learned by model perturbations are different from those of SHOT, the value of β used in SHOT may not be optimal.
Therefore, we search the optimal value β ∗ in range of [0.1,2.0] for all the three datasets.
Then, β ∗ is set to 0.3 in both Ofﬁce and Ofﬁce-Home.
The batch size is 64.
For Continual Online SFDA, we use the entropy loss as the likelihood function in Eq. 3.
In this way, the implementation is equivalent to a perturbation of Tent [18].
We use the same network architectures as in [17] to make the results comparable.
In CIFAR10-C, we employ WideResNet-28 [50] from
Robust Bench [51] as the backbone network.
We used the Adam [52] optimizer with learning rate 5e-4.
In CIFAR100-C tasks, we used ResNeXt-29 [53] from [54].
The optimizer settings are the same as that in CIFAR10-C except the learning rate is 7e-5.
In the ImageNet-C experiments, a pre-trained ResNet-50 is employed.
We adopt the Stochastic Gradient Descent optimizer with learning rate 1e-4, momentum 0.9 and weight decay 0.
In the testing phase, given a batch of target samples, we iterate the proposed method for only one epoch and make predictions immediately.
We set the scale parameter λ of the prior to be 1 . 0 .
We discuss the impact of different choices of priors on performance in Section 4.3.
In the target adaptation phase, we sample the perturbations once for running efﬁciency, while in the test phase, we sample the perturbations 10 times.
To reduce the sampling variance, we employ the local reparameterization trick [55].
The detailed optimization
[Figure] [Figure]
[Figure]
[Figure]
we learn a different σ for each parameter in the convolutional kernel individually; (c) Impact of layers without perturbations where the results are based on Ofﬁce-Home dataset and the backbone is ResNet-50. process with local reparameterization trick is in the supplementary material.
We also discuss the effect of different numbers of Monte Carlo samples on performance in the training phase in the supplementary material.
As for the compared methods, we either report the results in the original papers or the best results we can reproduce.
For the non-Bayesian methods, we run them 10 times with different random seeds and take the average of them to reduce randomness.
Apart from SHOT and Tent, we have also applied our variational model perturbation to other methods and report the results in the supplementary material.
Code is available at https://github.com/mmjing/Variational_Model_Perturbation .
4.3 Effectiveness Analysis
We present an effectiveness analysis of our method in Fig.
1, Fig. 2 and Fig.
Results of our method in the ofﬂine setting are from perturbed SHOT and in the online setting from peturbed Tent.
Quantiﬁcation of Weight Uncertainty.
In Fig.
1 we report a proxy of the weight uncertainty using the (cid:96) 1 -norm of the learned σ per layer.
We make the following observations: (1) In the ﬁrst few layers of the network, the perturbations are small.
As the layers go deeper, the perturbations become larger.
This shows that the shallower layers of the neural networks are more generalized, while the deep layers are task-speciﬁc, which is consistent with the ﬁndings in previous work [56, 38]; (2)
The extent of the perturbation is task-dependent.
A larger domain shift of the task needs a larger perturbation, which demonstrates that model perturbation effectively encodes uncertainty into the network, thus enhancing the generalization. [Table] [Figure] [Table]
(Ofﬁce-Home) and online tasks (CIFAR100-C).
Adaptive Prior.
In Fig.
2 (a) we report the impact of the variance scale factor of the prior on performance.
Compared to the isotropic
Gaussian prior, our adaptive prior has better performance and smaller ﬂuctuations for different scale factors.
This indicates that it is reasonable to use an adaptive prior as different weights may have different variation ranges when adaptation.
Our adaptive prior can specify different prior distributions for different weights according to the statistical properties within the convolutional kernels, leading to a better performance.
Parameter Sharing Strategy.
In Fig.
2 (b) we observe that the parameter sharing strategy achieves almost exactly the same performance compared with the non-sharing strategy.
For ResNet-50 based tasks, e.g., Ofﬁce and OfﬁceHome, the learnable parameters reduce from 24.03 million to 600 thousand compared with the non-sharing strategy.
As for the WideResNet-28 based tasks, e.g., CIFAR10-C, the learnable parameters reduce from 36.47 million to 30 thousand.
These results verify the effectiveness of the parameter sharing strategy.
Which Layers are Crucial for Perturbation?
We test the performance by keeping some of the network layers unperturbed.
As shown in Fig.
2 (c), we observe that the performance of the model degrades considerably when removing perturbations in the last few layers of the network, revealing that perturbations for the last few layers are crucial, since these layers are often task-relevant.
Adaptation Schemes.
In Fig.
3, we compare results of different updating schemes on Ofﬁce-Home and CIFAR100-C. BN modulation means only updating the statistics in the batch normalization layers.
Fine-tuning represents updating all the weights in the model.
We observe that model perturbations outperforms BN modulation and ﬁne-tuning in both the ofﬂine and online SFDA tasks.
Compared with BN modulation, model perturbation is more ﬂexible.
It can generalize the model to more target domains through perturbations.
Compared with Fine-tuning, model perturbation avoids the distortion of weight in the source model, which prevents the knowledge in the source domain from being forgotten in continuous adaptation.
Therefore, model perturbation is the better choice in SFDA tasks. [Table] [Table] [Table]
[Table] [Table] [Table] SHOT [7]
[Table]
This paper
[Table]
[Table]
4.4 Results
In this section, we provide the experimental results on ﬁve datasets under three different evaluation settings.
We also provide more detailed results in the supplemental material.
Ofﬂine SFDA.
We report the comparison results on Ofﬁce in Table 2 and Ofﬁce-Home in Table 3.
From the results we observe that the variational model perturbation achieves the best average results on Ofﬁce, showing the stronger generalization performance of the perturbed model.
Moreover, the variational model perturbation achieves the best results on 4 out of 6 tasks.
In particular, our method has improved by 1.4% compared with unperturbed SHOT.
A similar trend can be observed in the Ofﬁce-Home dataset, the variational model perturbation wins 9 taskes across all the 12 tasks.
In addition, our method outperforms SHOT by 1.0%, which proves that the variational model perturbation can consistently and clearly improve existing methods.
Generalized SFDA.
In Table 4 we report the results of model perturbation on Generalized SFDA tasks.
In this setting, we ﬁrst train the source model with 80% of the source data, and then adapt the model to the target domain.
Finally, we evaluate the model on both the target domain and the remaining 20% of the source data.
We observe that the performance of SHOT on the source domain decreases by 11.9% compared to the source model, indicating that SHOT forgets the knowledge learned in the source domain.
Compared to SHOT, model perturbation maintains the performance on the target domain while considerably improving the performance on the source domain, revealing that our model perturbation can maintain a good balance between adaptation and knowledge preservation.
Continual Online SFDA.
In Fig.
4 we report the test errors of different methods under the continual online SFDA, where all the methods continuously encounter 15 different types of corruption.
This experiment not only tests the real-time prediction performance of the compared methods, but also shows the degree of knowledge forgetting.
Note that Tent [18] only updates the parameters in the BN layers while Tent-FT (implemented by us) updates all the weights.
Similar to Tent, BACS [43] also employs entropy minimization, with the difference that BACS optimizes the model through a maximum-a-posteriori probability. [Figure]
In Fig.
4 (a) both AdaBN and Tent have test errors larger than 20.0%, revealing that the inﬂexibility of freezing the weights is the bottleneck for adapting to the continuously changing target domains.
By unfreezing the parameter update of the convolutional and FC layers, Tent-FT improves Tent by 0 .
Compared to Tent and Tent-FT, the implementation of model perturbation based on Tent achieves performance advantages of 2 . 8% and 1 . 9% , respectively, demonstrating that model perturbation is the better choice for SFDA tasks.
The performance advantages stem from two aspects.
First, model perturbation ﬁxes all the weights of the convolutional and FC layers to avoid large distortion of the weights and forgetting knowledge on the source domain.
Second, model perturbation introduces uncertainty into the model by slightly disturbing the weights, allowing it to adapt to continuous distribution shifts.
Similar conclusions can be drawn on CIFAR100-C and ImageNet-C.
Conclusion
In this paper, we address source-free domain adaptation in a probabilistic framework by variational model perturbation.
Instead of updating the network parameters by further optimization, we introduce perturbations to the weights of a pre-trained model from source domains.
We learn these perturbations through variational Bayesian inference.
Importantly, we prove the connection between variational model perturbation and Bayesian learning of a neural networks, which provides a theoretical guarantee for the generalization performance of model perturbation.
Moreover, with the parameter sharing strategy, we substantially reduce the learnable parameters compared to a fully Bayesian neural network, making the model perturbation a ﬂexible and lightweight framework.
Our variational model perturbation offers a new, probabilistic framework for source-free domain adaptation, which achieves efﬁcient adaptation while largely preserving the discriminative ability of the source model.
The experimental results on ﬁve benchmark datasets under three different evaluation settings reveal that model perturbation offers an effective way for source-free domain adaptation and boosts the performance considerably.
Acknowledgments and Disclosure of Funding
This work is ﬁnancially supported by China Scholarship Council (CSC).