Learning to Generalize across Domains on Single Test Samples
Authors: Zehao Xiao
Xiantong Zhen
Ling Shao
Cees G. M. Snoek
Venue: ICLR 2022 Poster (2022)
Keywords: domain generalization
single test sample generalization
meta learning
variational inference

Abstract: We strive to learn a model from a set of source domains that generalizes well to unseen target domains. The main challenge in such a domain generalization scenario is the unavailability of any target domain data during training, resulting in the learned model not being explicitly adapted to the unseen target domains. We propose learning to generalize across domains on single test samples. We leverage a meta-learning paradigm to learn our model to acquire the ability of adaptation with single samples at training time so as to further adapt itself to each single test sample at test time. We formulate the adaptation to the single test sample as a variational Bayesian inference problem, which incorporates the test sample as a conditional into the generation of model parameters. The adaptation to each test sample requires only one feed-forward computation at test time without any fine-tuning or self-supervised training on additional data from the unseen domains.  Extensive ablation studies demonstrate that our model learns the ability to adapt models to each single sample by mimicking domain shifts during training. Further, our model achieves at least comparable -- and often better -- performance than state-of-the-art methods on multiple benchmarks for domain generalization.

Published as a conference paper at ICLR 2022
LEARNING TO GENERALIZE ACROSS DOMAINS ON SINGLE TEST SAMPLES
Zehao Xiao Xiantong Zhen' 12, Ling Shao?, Cees G. M. Snoek!
AIM Lab, University of Amsterdam 'Inception Institute of Artificial Intelligence National Center for Artificial Intelligence, Saudi Data and Artificial Intelligence Authority
ABSTRACT
We strive to learn a model from a set of source domains that generalizes well unseen target domains. The main challenge in such a domain generalization scenario is the unavailability of any target domain data during training, resulting in the learned model not being explicitly adapted to the unseen target domains. We propose learning generalize across domains on single test samples. We leverage a meta-learning paradigm to learn our model to acquire the ability of adaptation with single samples at training time test sample at test time. We formulate the adaptation to the single test sample as variational Bayesian inference problem, which incorporates the test sample a conditional into the generation of model parameters. The adaptation to each test sample requires only one feed-forward computation test time without any fine-tuning or self-supervised training on additional data from the unseen domains. Extensive ablation studies demonstrate that our model learns the ability adapt models to each single sample by mimicking domain shifts during training. Further, our model achieves at least comparable and often better performance than taae-offtthe-ae methods on multiple benchmarks for domain generalization !.
to further adapt itself to each single
INTRODUCTION
Despite their widespread adoption and success in academia and industry alike, deep convolutional neural networks suffer from a fundamental flaw: they have insufficient generalizability to test data that is out of their training distributions (Recht et al., 2019). Improving the generalization of machine learning methods therefore remains challenging problem OMoreno-Torres et al., 2012; Recht et al., 2019; Krueger al., 2021). To deal with the distribution shift, domain adaptation (Saenko et al., 2010; Long et al., 2015; Lu et al., 2020; Li et al., 2021) and domain generalization (Muandet et al., 2013; Li al., 2017; 2020) have been extensively investigated. In domain adaptation, the key assumption is that the target data, either labeled or unlabeled, is accessible during training, which allows the model be adapted the target domains. However, this assumption does not necessarily hold in realistic scenarios where the target domain data is not available. By contrast, domain generalization strives to learn a model on source domains that can generalize well to unseen target domains without any access to the target domain data during training. We aim for domain generalization.
Previous domain generalization approaches have successfully explored domain- invariant learning (Muandet et al., 2013; Chattopadhyay et al., 2020) or domain augmentation (Shankar et al., 2018; Zhou et al., 2020a) to handle the domain shift between the source and target domains. However, since those models are trained on source domains, there will always be "adaptivity gap" when applying them to target domains without further adaptation (Dubey et al., 2021). Thus, it is necessary to train models that are able to further adapt to target domains without ever using target data during training.
Recently, further adapting pre-trained model using target domain data by fine-tuning or self- supervised training test time has shown effectiveness in improving performance domain generalization (Sun et al., 2020; Wang et al., 2021). To achieve proper adaptation to the target domain, these methods typically rely on extra fine-tuning operations target data extra networks (Dubey et al., 2021) at test time. Although some of these methods can achieve adaptation with a single test
Code available: https: / //gi thub. com wwwpe//www/....e n e eeGnera zatiiion on- ICIR2222

---

Published as a conference paper at ICLR 2022
Table 1: Training and test-time settings of learning methods for generalization across domains. (Xs, Ys) and X, denote the labeled source data and unlabeled target data. X indicates batches of samples, while x denotes just one sample. Our method does not need any target data during training, like (one-shot) domain adaptation methods, fine-tuning operations during inference. just uses single test samples to do per-sample adaptation for domain generalization.
Training
Test-time
Task
Method
Data
Fine-tune
Extra model
Adaptive
Domain
Common, e.g. (Long al., 2015)
X.. Y, X.
X
X
Adaptation
One-shot, c.g. (Luo al., 2020)
X., Yx
X1
x
Common, (Seo et al. 2020)
X., Y,
X:
Domain
Test time training (Sun et al., 2020)
X.. Y2
X;
Generalization
Test time adaptation (Wang
2021)
X.. Y,
X,,
Domain-adaptive method (Dubey et al., 2021)
X., Y,
X1,Xi
Single sample generalization
X., Y.2
X;
X
sample (D' Innocente et al., 2019; Sun et al., 2020; Banerjee et al., 2021), batches of target data are required for good performance. This prevents these methods from effectively adapting to the target domain when provided with very few target samples or exposed to test samples from multiple target domains without domain identifiers. Different from these works, we aim to learn the ability adapt to single sample such that the model can further adapt to each test sample from any target domain.
In this paper, we propose learning to generalize on single test samples for domain generalization. Since a sin- gle sample from the target distribution cannot inform much about the whole distribution, we consider each target sample a domain by itself. Corre- spondingly, we propose that each tar- get sample adjusts the trained model in its own way. This avoids the dif- ficulty of using the limited informa- tion available to adapt the model to the entire target domain distribution. An illustration of the method shown in Figure 1. Using meta-learning (Li et al., 2017). we train our model to acquire the ability to adapt with each single sample on source domains such that it can then adapt to each individual sample in the target domain to handle the domain shift at test time. Unlike previous methods, our model does not need to be fine-tuned using target data or train extra networks when generalized the unseen target domains. Once it is trained on source domains, our model is able to adapt to each single target sample with just feed-forward computation at test time, without the need for any extra target data. Note that not a single target sample is seen during training, which does not forgo the strict source and target separation setting of domain generalization. Moreover, in contrast to previous test-time adaptation methods (Sun et al., 2020; Wang et al., 2021; Dubey et al., 2021), our method does not need to re-adapt the model each target domain. Our model effortlessly handles test samples from multiple domains without knowing their domain identifiers.
Without adaptation
With adaptation
Classiliers
* Sample from domain
Samples from the source domsins
Figure 1: Illustration of single sample generalization. Dif- ferent colors denote different classes, Circles denote the clas- sifier prototypes for different categories. With our adaptation, the source features and the single target feature together de- fine new classifier prototypes, which are more adapted the target sample.
To be specific, we build model under the meta-learning framework and formulate the single sample generalization as a variational inference problem. In the training stage, we divide the source domains into several meta-source domains and a meta-target domain and explore the adaptive model by incorporating the information of the meta-target sample into the generation of the model parameters. For any given veta-target sample, we propose a variational distribution generated by this sample and the meta-source data to approximate the model distribution obtained by the meta-targe target data. In the test phase, the adapted models for the samples from the real target domains are generated on the fly by the variational model distribution. The random splits of the meta-source and meta-target domains expose the model to domain shifts and mimic the real generalization process from source domains to the target domain. Thus, the model is endowed with the ability to adapt to any unseen sample by end-to-end training with the source data only. By doing so, our method does not need to introduce any extra target data or fine-ture tamiettuing operations on the target domain. A comparison of the training/test-tinn time settings among different domain generalization (and domain adaptation) methods is summarized in Table 1.
2

---

Published as a conference paper at ICLR 2022
We demonstrate the effectiveness of our single sample generalization by conducting experiments on commonly used benchmarks for domain generalization. Our ablation studies under different domain generalization settings demonstrate the advantages of our method in comparison to other recent adaptive methods.
2 RELATED WORK
Domain adaptation To handle the domain shift between source and target domains, considerable efforts have been devoted to developing methods for domain adaptation (Long et al., 2015; Lu et al., 2020: Hoffman et al., 2018: 8; Kumar et al., 2010; Tzeng et al., 2017; Luo et al., 2019). However, the assumption that target data is accessible during training is often invalid. Recently, some even more challenging setrings were proposed in domain adaptation, e.g., few-shot (Motiian et al., 2017a) and one-shot domain adaptation (Dong& & Xing, 2018; Luo et al., 2020), but there are still a few or one target sample available during training. In this work, we focus on the more striet setting, domain generalization, that assumes not a single target sample is accessible during training. We construct our model under meta- veeta-leannnng framework to learn the ability of adaptation to single samples across source domains. At test time, no more learning is needed and we generate an adapted model for each individual target sample by only forward pass, without any extra fine-tuning operation.
Domain generalization The problem of domain generalization was introduced by Blanchard et al. (2011), and formally posed by Muandet et al. (2013). Muandet et al. (2013) and Ghifary et al. (2016) both considered domain-invariant learning by minimizing the dissimilarity of features across source domains. Following these works, many methods explored domain invariant learning for domain generalization (Motian et al., 201 7b; Rojas-Carulla et al., 2018; Li et al., 201 88;; Seo et al., 2020; Zhao et al., 2020). Alternatively, augmenting the source domain data has been explored to simulate more domain shift during training (Shankar al., 2018; Volpi et al., 2018: Zhou et al., 2020a; Qiao et al., 2020; Zhou et al., 2020b). Our method tackles domain shift by learning to adapt to each unseen target sample, which is orthogonal to domain-invariant and domain augmentation methods.
Domain meta-learning Meta-learning methods have also been studied for domain generalization (Balaji et al., 2018; Du et al., 2020; Xiao al., 2021; Du et al., 2021). Li et al. (201 8a) introduced the model agnostic meta-learning (Finn et al., 2017) into domain generalization. Dou et al. (2019) further enhanced the method with global and local regularization. We follow the experimental settings of previous methods (Du et al., 2020: Xiao et al., 2021) that split source domains into soetae and meta- meta-target domains. By mimicking the adaptation process at training time, our model learns to learn the adaptable classifiers from meta-source domains and the meta-target sample.
Test-time adaptation Recently, several methods have proposed to adapt a model trained on source data to unseen target data at test time ID'Innocente et al., 2019; Sun et al., 2020; Wang et al., 2021; Dubey et al., 2021). Sun et al. (2020) trained their model on source domains with both supervised and self-supervised objective functions, and then fine-tuned it on target data with only the self-supervised one. Wang et al. (2021) further improved this method by removing the sulf-supe module, while fine-tuning the model with entropy minimization loss. Differently, Dubey et al. (2021) trained domain embedding network with unsupervised source data, which is utilized to generate the target domain embedding by hundreds of unlaheled target samples adapt the model at test time, without fine-tuning or further training. These adaptive methods all need extra steps, e.g., fine-tuning the model or training embedding networks, and batches of target samples for good adaptation. In contrast, our method learns to adapt to each target sample using just its own information without any extra target samples and fine-tuning me-tunnng operations. The adaptation is achieved by generating the model for each target sample with only one forward pass. Another recent work utilized test-time augmentation to improve robustness at test time (Chai et al., 2021). While it is of interest to adapt a test-time sample to source domains with such test-time augmentations, our method aims to adapt the model trained by source domains to each target sample.
3 METHODOLOGG
In domain generalization, several domains are defined as different data distributions in the joint space X x V. where X' and y denote the input space and the label space. The domains are divided into non-overlapping source domains, collectively denoted as S and the target domains T. During training, only data from source domains is accessible. Data from target domains is never seen. Our goal is to learn model on the source domains only that generalizes well to the target domains. As
3

---

Published as a conference paper at ICLR 2022
we focus on homogeneous domain generalization (Zhou et al., 2021) in this work, all domains share the same label space.
Since the target data is inaccessible during training, we design a meta-learning framework with episodic training (Li et al., 2019; Balaji et al., 2018) that endows the model with the capability of learning to generalize on single test samples from any unseen domain. To this end, according to the precise domain annotations (if available) or image clusters, we divide the source domain(s) S into several meta-source domains S' and a meta-target domain T' in each iteration expose the model to domain shifts. After training, the learned model is applied to the target domain T for evaluation. In this case, the model is exposed to different domain shifts to learn the ability to handle it. After training. the learned model is applied to the target domain T for evaluation.
Variational learning We develop our model under the probabilistic framework. Assume we have a single sample X from the meta-targed domain T', and we would like to predict its class label yr- We consider the conditional predictive log- likeliihood pogg((yexxe (xe, T'). By incorporating the model Or into the prediction distribution, we have
log ply Xx, T log p(ye/>xe, D(xe:lsx,,00)p00:1 (r)
where we condition the prediction on T' to leverage information from the meta-target data and (Xe,yr) denotes the onput-output pair of the meta-target sample. We refer to p(Or(T') as the meta-prior distribution since it is conditioned on the meta-target data.
However, in practice, the labeled data from the target domain is inaccessible, leading an intractable distribution p(0,) (T) during inference. To address the problem, we propose to approximate the model function p(0, (T) with the accessible source data by the variational inference approach, which provides a framework to approximate intractable distributions via optimization. By training under the meta-learning framework, our method will learn the ability approximate the model functions of unseen target domains by source domain data.
Variational domain generalization We introduce a variational distribution ((rr((')) to approximate the true posterior over the model parameters 0. By incorporating g(0r) (S') into eq. (1), we derive lower bound of the conditional predictive log- lieeliiieiooo:::
log Ply (xe, T') = log / plyelze, (r)
( [log p(yr 0z) Dk (0,
The introduced Kullhack-Leibler (KI.) divergence term is minimized to reduce the distance between (0pr (S') and I(O,)T"', which encourages the model 0 inferred by g(Or'S')) from meta-source domains to be generalizable to the meta-target domain.
Although eq. (2) reduces the difference between the variational distributions ((,, (S)) and p(0gr IT'), q(p (S') still has limited capacity of handling the meta-target samples due to "adaptivity gap" (Dubey et al., 2021). Since only little information about the meta-target domain T' and the meta-target sample x, is available in S', there is no guarantee that the variational distribution ((rr will be adapted to the meta-target domain T'. To reduce the "adaptivity gap", the model needs to acquire the ability to effectively use the target information. Thus, we further propose to learn to adapt the model Or by taking more information of the meta-target data into account.
Single sample generalization In domain generalization, especially for real applications, when given data from an unseen target domain, the only accessible information of the target data is from the target sample, without any annotations. We therefore propose to utilize the information contained in the given target sample to construct the adapted model. Instead of utilizing ((rr as the variational distribution, incorporate the meta-target sample X into the variational distribution ((0r [xe, S') to approximate the true posterior distribution. Given an unlabeled sample x from the meta-target domain T', we have new evidence lower bound (ELBO) follows:
log p(ye (xv, T') = =log| f plye xv. 0 p 0 ,.
2 R.....)) [lo
((yggp((ylll)r Xxe 0v)) DKI. (g(O xv. ('))''(((OO(
By conditioning on the given sample x and the source data S'. the adapted variational distribution q( Or Xv. S') contains both the categorical information provided by the meta-source data and the
4

---

Published as a conference paper at ICLR 2022
domain information given by the meta-target sample. This to a large extent guarantees the inferred model to be discriminative and adapted to the given meea-target domain sample. Moreover, the KL divergence in eq. (3) further acts regularizer to guide the variational distribution to be similar to the parameter distribution p( (T') obtained by the meta-target data, which is assumed to be the most suitable parameter for the meta-target sample Xy- This makes the model better adapted to X
Based on the meta-learning framework and eq. (3), our model learns the ability to adapt the meta- source model each meta-target instance across different domain shifts. The learned ability is exploited to handle domain shifts at test time by adapting the source model to each target instance. During inference, our method directly uses the variational distributions q(e, Xx S) as the adapted model generated by the information of the given target sample x, and the data from all source domains S. Thus, the method is able to generalize to each unseen target sample without the requirement of any extra data from the target domains or fine-tuning operations. The derivations of eq. (2) and eq. (3), as well as more discussions on their tightness are provided in Appendix A.
Learning to adapt classifiers The variational inference framework in eq. (3) indicates that we can learn to adapt all model parameters 0 to the target sample. This could, however, be computationally infeasible due to the large number of parameters in the network. Thus, for computational efficiency and feasibility we utilize the features from the feature extractor as the sample-specific information to construct the adapted classifier, which contains much fewer parameters.
To do so, divide the model @ into feature extractor & and classifier w. The feature extractor is shared across domains, while the classifier is trained to be adapted to each single sample by eq. (3). Both the meta-prior distribution p(w,r (T') and the variational posterior distribution g(W,r ( of the classifier We are generated by amortized inference using the amortization technique (Kingma & Welling, 2013; Gershman & Goodman, 2014; Gordon al., 2019; Shen al., 2021). The amortization technique provides natural way to generate model parameters by feature representations, which is one appropriate solution for our method to incorporate the target feature into the construction of the adapted variational posterior distribution. Moreover, the amortization networks can be trained and evaluated together with the model, without introducing extra training steps and fine-tuning operations to achieve the adaptation ability. Specifically, we use the center features of samples in each class from the meta-target domain and meta-source domains as the representatives of T' and S We generate the meta-prior distribution p( w. (T') by taking the center features of T' as input to the amortized inference network A.. For the variational distribution g(we/ Xg, S'), the input to the amortized inference network is the concatenation of the center features of the meta-source domain S' with the features of the target sample xe for adaptation. The amortized inference network 0,, is shared for the inference of both the meta-prior and posterior distributions.
However, the direct concatenation operation is not necessarily optimal as the input for the amortized inference network. We propose to generate the parameter distribution using the meta-source domains and then adapt it with the given meta-target sample. To do so, we first generate a classifier distribution p( ((w,'('') using the center features of the meta-source data S'. After that, we take p(W,'\S') as prior and combine it with the meta-target sample to estimate the variational posterior, as follows:
g(we) X S') = p( (We [xv, ws (P(Ww/lS')dww
This establishes a hicrarchical variational inference of the posterior distribution. We show in our experiments that the hierarchical inference yields better results than the direct concatenation. In practice, we approximate the integral by:
(x, S') Σ (iWelxyr w!
(5)
where w!!) p(w,' (S') and T. the number of Monte Carlo samples.
The negative KL. divergence term in eq. (3) tries to close the gap between the variational adaptive distribution q( (wr S') and the meta-prior distribution p( IT') aiming to make the variational distribution adapt better to the target data. However, there is no guarantee that the classifier produced by the meta- -eetar-rioori is discriminative enough for classification. To address this issue, we introduce an intermediate supervision based the meta-prior distribution make it as predictive as possible, by maximizing:
I Fp (T) [log p(ye Xx,, we)]-
5

---

Published as a conference paper at ICLR 2022
T
S
T
W
W!
W
W
Ye
(a) Training on meta-source (S") and meta-target (T') domains
(b) Testing the domain (7)
Figure 2: Illustration of single sample generalization using meta-learning. Through variational Bayesian inference, we incorporate the single sample as a conditional during the generation of model parameters. The dashed line indicates training only.
This is also implemented as a cross-entropy loss using Monte Carlo sampling from the meta-prior.
Empirical objective function
By incorporating eq. (5) and eq. (6) into eq. (3), we obtain the final
empirical objective function:
M
N log plye XV, w )- - DKL (
log logp(yr|xe.
w. (()))
+
pl (we (xy, w w )lp))l (T')
m=
==1
8=1
(7)
where we use Monte Carlo sampling: w (m)
Ele gWwrl//e w
and w. (m) ~ p(WwelT)).
As illustrated in Figure 2, at training time (a), we train the model episodi- cally on meta-source domains S' and a meta-target domain T. At infer- ence time (b), given single sample X₁ from the target domain T, we use adapt the W, gener- ated by the source data. The adap- tation is achieved by generating the adapted classifiers w, for each target sample with only one forward pass us- ing the learned amortization inference network O.. The detailed architecture is provided in Figure 3. We also pro- vide an algorithm in Appendix B.
S
MLP
p( ((W
Sampling
Concat
0g
a( (we))
MLP
Posterior
this sample
X²'
CNN Ø
Prior
T
0g
p ((wy)
Ye
Figure 3: Architecture of single sample generalization. S' and T' denote meta-source and meta-target. xy and yr de- note the input image and prediction of the single test sample.
4 EXPERIMENTS
We conduct our experiments four widely used benchmarks for domain generalization: PACS (Li et al., 2017), Office-Home (Venkateswara et al., 2017), rotated MNIST, and Fashion-MNIST (Piratla al. 2020). The details of the datasets and our implementations are provided in Appendix C.
Benefit of single sample generalization We first investigate the effectiveness of our single sample generalization on the PACS dataset. To demonstrate the benefits of all components of our method, we consider four settings: (i) the "variational amortized classifier" with eq. (2) as the objective function, (ii) our single sample generalization method without hierarchical architecture (eq. 5), (iii) single sample generalization without supervision on the meta-prior distribution (eq. 6), and (iv) the entire single sample generalization method, with the objective function in eq. (7). Results based on the ResNet- 18 backbone are shown in Table 2.
By comparing rows and Table 2, it is clear that our single sample generalization brings an improvement in accuracy over the invariant amortized classifier, especially on the "art-painting" and "cartoon" domains. These results demonstrate the benefits of introducing the information of the given target sample into the model generation. The comparison also demonstrates that model learns the capability to adapt to the target sample using its own information. Comparing the last two rows shows the benefits of the intermediate supervision in eq. (6), which provides more discriminative

---

Published as a conference paper at ICLR 2022
Table Benefits of single sample generalization. Ablation study on PACS using ResNet- aver- aged over five runs. Best runs within a 95% confidence margin bolded. Single sample generalization more effective than the invariant amortized classifier. The hierarchical architecture further improves the performance. Intermediate supervision the prior distribution is also important.
Settings
Photo
Art- painting
Cartoon
Sketch
Mean
Invariant amortized classifier (eq. 2)
95.19 +0.30
79.34
10.65
78.04 =085
76.21 4054
82.19
1:035
Single sample generalization (w/o eq. 5)
95.69 +0.20
81.06
10.33
79.20
20.19
77.10
1061
83,26
10.31
Single sample generalization (w/o eq. 6)
95.47
20:20
80.00
#0.61
77.87
=001
77.20
408s
82.64
+0.32
Single sample generalization (eq. 7)
95.87 1:224
82.02
#0.36
79.73
=0.49
78.96
10.67
84.15
0.21
Table 3: Importance of appropriate domain shift during training on PACS using ResNet-18 averaged over five runs. The more appropriate the domain shift encountered during training, the better our method will perform during inference.
Division of source domains
Photo
Art-painting Cartoon
Sketch
Mean
Split images randomly
95.75 #0.24
78.30
+0033
78.52
#081
75.69
#0.64
82.07
+0.11
Split by image clusters
95.67 #0.39
80.05
+0056
79.39
10.00
77.12 10.00
83.06
+0.39
Split by domain annotations
95.87 20:21
82.02 10036
79.73
20.49
78.96
-0.67
84.15 +021
Table 4: Ablation of meta-learning setting. The experiments are conducted on PACS using ResNet- 18 averaged over five runs. Under the meta-learning framework (second row), the method performs better on all domains.
Settings
Photo
Art-painting
Cartoon
Sketch
Mean
w/o Meta-learning
94.61 #0.65
79.97
#0.13
78.45
=0.29
75.83
#0.79
82.21 #0.36
Meta-learning
95.87 +0.24
82.02 10.36
79.73
#0.49 78.96 20.67
84.15 10:1
meta-prior distribution during training to learn more adapted variational distribution, especially on the "art- nut-ppinning", "cartoon" and "sketch" domains. Results in rows 2 and 4 of Table 2 show that the hierarchical architecture for the variational adaptive classifier q( ) provides a more adapted model for each target sample and achieves the best performance on all domains.
Importance of appropriate domain shift during training To show the importance of mimicking an appropriate domain shift during training, we conduct experiments with different divisions of source domains during training. As shown in Table 3, when we randomly split images into source domains (row 1), the domain shift between them is too small to mimic the domain shift between source and target domains. Thus, the performance are not so good, especially on "art-painting" and "sketch". When split the source domains with image clusters (row 2) and precise domain annotations (row 3), the performance is improved, demonstrating the importance of constructing appropriate domain shift during training. By better mimicking domain shifts during training. our method achieves better performance. Importantly, the experiments also show that our method can improve the performance without the need to have multiple domains and annotations by a simple unsupervised domain split method, e.g., clustering. The conclusion is also demonstrated in the single-source domain experiments that are provided in Table 11, Appendix D.
Ablation of meta-learning setting To show the importance of the meta-learning framework, we also implement a non-meta-less me--eeeel-lannng version of our method. We directly generate the adapted classifiers by features from all source domains and the feature representations of the single sample. The results are shown in Table 4. Without the meta-learning framework, the model has difficulty to learn the ability to adapt to unseen domains and tends to overfit to the source domains. Thus the performance on all domains is worse than the meta-learning-bel based model.
Influence of backbone To show the influence of backbone models on the single sample generalization, we further compare our proposal with a baseline empirical risk minimization (ERM) method on PACS by varying the backbone model size. As shown in Table 5, our method achieves more obvious performance gains with larger backbone models compared to the ERM baseline. We explain this by use of amortized inference network that generates the classifier by the source domain features and the target sample feature. Implying an increase in backbone capacity has a direct effect on our classifier capacity, enabling better adaptation to the target sample.
Visualization of single sample generalization To illustrate the benefit of incorporating the test sample into classifier generation, we visualize the the target features and the classifiers of both the
7

---

Published as a conference paper at ICLR 2022
Table 5: Influence of backbone. The experiments are conducted on PACS over five runs. Only the average accuracy of four domains is shown in the Table. With larger and larger backbone models, our method achieves better and better performance gaps compared to the ERM baseline.
Method
AlexNet
ResNet-18
ResNet-34
ResNer-50
ERM baseline
71.23 #0.38
81.45 10.21
82.58 #0.36
84.09
#0.13
Single sample generalization
72.50 20.28
84.15 +0.1
85.91 10.38
87.51 #0.22
Baseline
Single sample generalization
An eiephant sample
girofff sample
A person sample
Classifiers:
Elephant
Dog
Giraffe
House
Person
Figure 4: Visualization of single sample generalization on the "cartoon" domain from PACS. Different shapes denote different categories. Samples are in red, classifiers in blue. Single sample generalization generates adapted classifiers for different target samples, leading to better classification.
"variational amortized classifier" (baseline) and our single sample generalization method in Figure 4. We treat the vectors of different categories in the classifier as prototypes with the same dimension as the test features and map the classifier vectors and features into the same 2D space. As shown in the left figure (baseline), the classifier parameters of the "invariant amortized classifier" on source domains and fixed for all target samples. In contrast, as shown in the three figures on the right, our method generates specific, adapted classifiers for each test target sample. For instance, the test sample (+) has the shortest distance to the adapted classifier of its own class ), producing the correct predictions. More visualizations, including failure cases, are provided in Appendix E.
trained
Single sample generalization vs. Tent Next we conduct an experiment on rotated-MNIST to compare our method with Tent by Wang et al. (2021), which is recent test-time adaptation method that fine-tunes the model with batches of target samples. We follow the setting in (Piratla et al., 2020) and generalize seven domains by rotating the samples by 09 to 90º in intervals of 15a, To make the target domains more different from each other, we use images rotated by 0%, 455 and 90 as target domains, 15,, 30, 60 and 75 as source domains. For fair comparisons, we train the base model of Tent using data from all source domains, which is the same amount of train and validation data as in our method. Then, the trained base model adapted by the target samples as in the original paper of Tent. The other settings are the same as our methods. As shown in Figure 5, we design two settings for Tent for the comparisons: "single target domain" (left) and "multiple target domains" (right). In the "single target domain" setting, we adapt the base model to each of the target domains separately using Tent and take the average accuracy of different domains. For "multiple target domains". Tent is required to adapt to all three target domains jointly without the domain identifiers. Since our method is able to adapt to each sample, the performance is consistent under both settings.
As expected, Tent achieves good adaptation for large batch sizes (e.g., 128) from single target domain. However, when there are only very few samples, and ultimately just one sample. the adaptation of Tent starts suffer, and may even hurt accuracy. Tent, like other test-time adaptive domain generalization methods, relies on a batch of samples to adapt to the target domain. In other words, the test samples have known domain identifiers. However, in practical settings, the test samples might come from different domains and the domain identifiers may be inaccessible. Thus, we also explore the effectiveness under the "multiple target domains" setting, as shown in Figure 5 (right). In this scenario, the adaptability of test-time adaptation methods like Tent, starts to decline, even with more samples. In contrast, our method learns the capability to adapt to each sample from any target domain, overcoming the lack of target samples while being robust under multiple target domains. We also compare our method with Tent on PACS and Office-Home. The results are shown in Table 6. We perform Tent with a baseline model trained on all source domain data, which is then fine-tuned by 128 target samples for 100 iterations. The conclusion is the same as rotated MNIST. Our method achieves better performance. One reason can be that our model
All Tent results are obtained by running the author-provided code accompanying (Wang et al., 2021).
8

---

Published as a conference paper at ICLR 2022
Single target domain
Multiple target domains
97.0
97.0
96.5
96.5
Accuracy
96.0
Accuracy
95.5
95.5
Rose Model
Single generalization
95.0
step!
95.0
(10 steps]
94.5
Wilt (100 stmse]
94.3
128
64
128
Number samples
Number of samples
Figure 5: Single sample generalization vs. Tent (Wang al., 2021) for different settings on rotated-MNIST. Tent shows good performance with a large batch of samples from single domain (left). However, when provided only one sample given samples from different domains without the domain id (right), Tent suffers. More detailed comparisons are provided in Appendix F.
Table 6: Comparison on PACS and Office-Home. Our method achieves best mean accuracy with a ResNet-50 backbone and is competitive with ResNet-18. Notably, it surpasses the adaptive methods by Wang et al. (2021) and Dubey et al. (2021), despite them using more data at test-time (Table 1).
PACS
Office-Home
Method
ResNet-18
ResNet-50
ResNet-18 ResNet-50
Carlucci et al. (2019)
80.51
61.20
Dou et (2019)
81.04
82.67
Zhao et al. (2020)
81,46
85.34
Zhou al. (2020a)
82.83
84,90
65.63
67.66
Seo al. (2020)
85.11
86.64
62.90
Gulrajani Lopez-Paz (2020)
85,50
66.50
Dubey et al. (2021)
84.50
68.90
Wang et al. (2021)²
83.09
10013
86.23
+0.22
64.13
10.16
67.99
=0.22
Single sample generalization
84.15
#0.21
87.51
#:022
66.02
=0028
71.07
=0.31
adapts the model to each individual target sample rather than the entire target domain. Thus, different adaptations are conducted different target samples. Alternatives are sensitive to the chosen batch of samples, which is not necessarily generalizable to the entire domain, especially when the batch is small. Another reason is our choice for meta-learning. By mimicking the adaptation process under the meta-learning framework, the model learns the ability to adapt to single target sample. Without meta-learning, as shown in Table 4, the performance drops.
Comparisons with state of the art Finally, we compare our method with the state-of-the-art on four datasets. The results PACS and Office-Home are reported in Table 6. Our method achieves good performance with both the ResNet- 18 and ResNet-50 backbones. Compared with others. our method shows larger advantages with ResNet-50 than ResNet- 18 on both PACS and Office- Home. This is reasonable since we generate the adaptive model using the features of source and single target samples, which contain more information with ResNet-50, leading to more adapted models. This is also demonstrated in Table 5. Results per domain, well as the results rotated-MNIST and Fashion-MNIST are provided in Appendix D.I, with similar results and conclusions.
CONCLUSION
We propose learning to generalize by single test samples for domain generalization. Our model able to adapt to any unseen target sample by leveraging the information the given sample to generate the model. We formulate the adaptation process variational inference problem and train the model under the meta-learning framework. After training on the source data, our method can adapt to each sample from the unseen target domains without any fine-tuning operations extra target data. Ablation studies and further experiments on several benchmarks show the effectiveness of our method.

---

Published as a conference paper at ICLR 2022
ACKNOWLEDGMENT
This work is financially supported by the Inception Institute of Artificial Intelligence, the University of Amsterdam and the allowance Top consortia for Knowledge and Innovation (TKIs) from the Netherlands Ministry of Economic Affairs and Climate Policy.
ETHICS STATEMENT
With the capability handle the domain shift without the accessibility of target data during training and fine-tuning operations, our method has potential positive impacts in the applications that often face unseen domains in practice, e.g., medical imaging and automatic driving. Accordingly, our method would also potentially face some negative social impacts accompanying with applications, e.g,, lack of fairness with the model trained by incomplete data and the privacy patients in medical imaging.
REPRODUCIBILITY STATEMENT
To reproduce our method, the details the method and loss functions are provided Section 3. We also provide the derivations and discussions about the evidence lower bound used in our method in Appendix A. The datasets used in this paper and the detailed implementations of the method are reported in Appendix C. An illustration of the architecture is shown in Figure 3. We also provide link to the source code of our method the Abstract.
REFERENCES
Yogesh Balaji, Swami Sankaranarayanan, and Rama Chellappa. MetaReg: Towards domain gen- eralization using meta-regularrization. In Advances in Neural Information Processing Systems, volume 31, pp. 998-1008, 2018.
Pratyay Banerjee, Tejas Gokhale, and Chitta Baral. Self-supervised test-time learning for reading comprehension. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 1200-1211, 2021.
Gilles Blanchard, Gyemin Lee, and Clayton Scott. Generalizing from several related classification tasks to new unlabeled sample. In Advances in Neural Information Processing Systems, volume 24, pp. 2178-2186, 2011.
Fabio M Carlucci, Antonio D' D'Innocente, Silvia Bucci, Barbara Caputo, and Tatiana Tommasi. Domain generalization by solving jigsaw puzzles. In IEEE Conference on Computer Vision and Pattern Recognition, pp.
2019.
Lucy Chai, Jun-Yan Zhu, Eli Shechtman, Phillip Isola, and Richard Zhang. Ensembling with deep generative views. In JEEE Conference Computer Vision and Pattern Recognition, pp- 14997-15007, 2021.
Prithvijit Chattopadhyay, Yogesh Balaji, and Judy Hoffman. Learning to balance specifieity and invariance for in and out of domain generalization. In European Conference on Computer Vision, pp. 301-318. Springer, 2020.
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. ImageNet: A large-scale hierarchical image database. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 248-255, 2009.
Antonio D' D'Innocente, Silvia Bucci, Barbara Caputo, and Tatiana Tommasi. Learning to generalize one sample at time with self-supervision. arXiv preprint arX1v:1910.03915. 2019.
Nanqing Dong and Eric P Xing. Domain adaption in one-shot learning. In Joint European Conference Machine Learning and Knowledge Discovery in Databases, pp. 573-588. Springer, 2018.
10

---

Published as a conference paper at ICLR 2022
Qi Dou, Daniel C Castro, Konstantinos Kamnitsas, and Ben Glocker. Domain generalization via model-agnostic learning of semantic features. In Advances in Neural Information Processing Systems, 2019.
Yingjun Du, Jun Xu, Huan Xiong, Qiang Qiu, Xiantong Zhen, Cees G M Snoek, and Ling Shao. Learning to learn with variational information bottleneck for domain generalization. In European Conference Computer Vision, pp.
2020.
Yingjun Du, Xiantong Zhen, Ling Shao, and Cees G M Snoek. MetaNorm: Learning normalize few-shot batches across domains. In International Conference on Learning Representations, 2021.
Abhimanyu Dubey, Vignesh Ramanathan, Alex Pentland, and Dhruv Mahajan. Adaptive methods for real-world domain generalization. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 14340-14349, 2021.
Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-leamiing for fast adaptation of deep networks. In International Conference Machine Learning, pp. 1126-1135. PMLR, 2017.
Samuel Gershman and Noah Goodman. Amortized inference in probabilistic reasoning. In Proceed- ings of the Annual Meeting of the Cognitive Science Society, volume 36, 2014.
Muhammad Ghifary, David Balduzzi, W Bastiaan Kleijn, and Mengjie Zhang. Scatter compo- analysis: A unified framework for domain adaptation and domain generalization. IEEE Transactions on Pattern Analysis and Machine Intelligence, (9(7):141--143) 2016.
Jonathan Gordon, John Bronskill, Matthias Bauer, Sebastian Nowozin, and Richard E Turner. Meta- learning probabilistic inference for prediction. In International Conference on Learning Represen- tations, 2019.
Ishaan Gulrajani and David Lopez-Paz. In search of lost domain generalization. In International Conference on Learning Representations, 2020.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 770-778, 2016.
Judy Hoffman, Eric Tzeng, Tacsung Park, Jun-Yan Zhu, Phillip Isola, Kate Saenko, Alexci Efros, and Trevor Darrell. Cycada: Cycle-consistent adversarial domain adaptation. In International Conference on Machine Learning, pp. 1989-1998. PMLR, 2018.
Zeyi Huang, Haohan Wang, Eric P Xing, and Dong Huang. Self-challenging improves drosin generalization. In European Conference on Computer Vision, pp. 124-140, 2020.
Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.61 14, 2013.
David Krueger, Ethan Caballero, Joern-Henrik Jacobsen, Amy Zhang, Jonathan Binas, Dinghuai Zhang, Remi Le Priol, and Aaron Courville. Qut-of-disti generalization via risk extrapola- tion. In International Conference on Machine Learning, pp. 5815 5815-5826. PMLR, 2021.
Abhishek Kumar, Avishek Saha, and Hal Daume. Co-regularization based supeesupee domain adaptation. In Advances in Neural Information Processing Systems, volume 23, pp. 478 4866,4866688 2010.
Bo Li, Yezhen Wang, Shanghang Zhang, Dongsheng Li, Kurt Keutzer, Trevor Darrell, and Han Zhao. Learning invariant representations and risks for supe-super domain adaptation. In IEEE Conference on Computer Vision and Patlern Recognition, pp. 1104-1113, 2021.
Da Li, Yongxin Yang, Yi-Zhe Song, and Timothy M Hospedales. Deeper, broader and artier domain generalization. In JEEE International Conference on Computer Vision, pp. 5550, 2017.
Da Li, Yongxin Yang, Yi-Zhe Song, and Timothy Hospedales. Learning to generalize: Meta- Meta-lcarning for domain generalization. In AAAI Conference Artificial Intelligence, volume 32, 201 Sa.
Da Li, Jianshu Zhang, Yongxin Yang, Cong Liu, Yi-Zhe Song, and Timothy M Hospedales. Episodic training for domain generalization. In IEEE International Conference on Computer Vision, pp. 1446-1455, 2019.
11

---

Published as a conference paper at ICLR 2022
Haoliang Li, YuFei Wang, Renjie Wan, Shiqi Wang, Tie-Qiany Rioagian Li, and Alex C Kot. Domain generalization for medical imaging classification with dependdeyyy regularization. arXiv preprint arXiv:2009. 2020.
Ya Li, Mingming Gong, Xinmei Tian, Tongliang Liu, and Dacheng Tao. Domain generalization via conditional invariant representations. In AAAI Conference on Artificial Intelligence, volume 32, 2018b.
Mingsheng Long, Yue Cao, Jianmin Wang, and Michael Jordan. Learning transferable features with deep adaptation networks. In International Conference on Machine Learning, pp. 97-105, PMLR, 2015.
Zhihe Lu, Yongxin Yang, Xiatian Zhu, Cong Liu, Yi-Zhe Song, and Tao Xiang. Stochastic classifiers for unsupervised domain adaptation. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 1110- 2020.
Yawei Luo, Liang Zheng, Tao Guan, Junqing Yu, and Yi Yang. Taking a closer look at domain shift: Category-level adversaries for semantics consistent domain adaptation. In IEEE Conference Computer Vision and Pattern Recognition, pp. 2507-2516, 2019.
Yawei Luo, Ping Liu, Tao Guan, Junqing Yu, and Yi Yang. Adversarial style mining for one- shot unsupervised domain adaptation. In Advances in Neural Information Processing Systems, volume 33, 2020.
Jose G Moreno-Torres, Troy Raeder, Rocío Alaiz-Rodríguez, Nitesh V Chawla, and Francisco Herrera. A unifying view dataset shift in classification. Puttern Recognition, 45(1):521-530, 2012.
Saeid Motian, Quinn Jones, Seyed Iranmanesh, and Gianfranco Doretto. Few-shot adversarial domain adaptation. In Advances in Neural Information Processing Systems, volume 30, pp- 6670-6680, 2017a
Saeid Motiian, Marco Piccirilli, Donald A Adjeroh, and Gianfranco Doretto. Unified deep supervised domain adaptation and generalization. In IEEE International Conference on Computer Vision, pp. 5715-5725, 2017b.
Krikamol Muandet, David Balduzzi, and Bernhard Schölkopf. Domain generalization via invariant feature representation. International Conference on Machine Learning, pp. 10-18. PMLR, 2013.
Vihari Piratla, Praneeth Netrapalli, and Sunita Sarawagi. Efficient domain generalization via common- specific low-rank decomposition. In International Conference on Machine Learning, pp. 7728- 7738. PMLR, 2020.
Fengchun Qiao, Long Zhao, and Xi Peng. Learning learn single domain generalization. In IEEE Conference on Computer Vision and Puttern Recognition, pp. 12556-12565, 2020.
Benjamin Recht, Rebecca Roelofs, Ludwig Schmidt, and Vaishaal Shankar. Do imagenet classifiers generalize imagenet? In International Conference on Machine Learning, pp. 5400. PMLR, 2019.
Mateo CcoaasCarrlle Bernhard Schölkopf, Richard Turner, and Jonas Peters. Invariant models for causal transfer learning. Journal of Machine Learning Research, 19(1):1309 1342, 2018.
Kate Saenko, Brian Kulis, Mario Fritz,, and Trevor Darrell. Adapting visual category models to new domains. In European Conference Computer Vision, pp. 213-226 2010.
Seonguk Seo, Yumin Suh, Dongwan Kim, Geeho Kim, Jongwoo Han, and Bohyung Han. Learning to optimize domain specific normalization for domain generalization. European Conference on Computer Vision, pp. 68 88-83, 2020.
Shiv Shankar, Vihari Piratla, Soumen Chakrabarti, Siddhartha Chaudhuri, Preethi Jyothi, and Sunita Sarawagi. Generalizing across domains via cross- gradient training. In International Conference Learning Representations, 2018.
12

---

Published as a conference paper at ICLR 2022
Jiayi Shen, Xiantong Zhen, Marcel Worring, and Ling Shao. Variational multi-tas learning with gumbel-softmax priors. In Advances Neural Information Processing Systems, volume 34, 2021.
Baochen Sun and Kate Saenko. Deep coral: Correlation alignment for deep domain adaptation. In European Conference on Computer Vision, pp. 443-450, 2016.
Yu Sun, Xiaolong Wang, Zhuang Liu, John Miller, Alexei Efros, and Moritz Hardt. Test-time training with superviinn for generalization under distribution shifts. In International Conference on Machine Learning, pp. 9229-9248. PMLR, 2020.
Eric Tzeng, Judy Hoffman, Kate Saenko, and Trevor Darrell. Adversarial discriminative domain adaptation. In IEEE Conference Computer Vision and Pattern Recognition, pp. 7167-7176. 2017.
Hemanth Venkateswara, Jose Eusebio, Shayok Chakraborty, and Sethuraman Panchanathan. Deep hashing network for unsupervised domain adaptation. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 5018-5027, 2017.
Riccardo Volpi, Hongseok Namkoong, Ozan Sener, John Duchi, Vittorio Murino, and Silvio Savarese. Generalizing to unseen domains via adversarial data augmentation. In Advances Neural Information Processing Systems, volume 31, pp. 5339-5349, 2018.
Dequan Wang. Evan Shelhamer, Shaoteng Liu, Bruno Olshausen, and Trevor Darrell. Tent: Fully test- time adaptation by entropy minimization. International Conference on Learning Representations, 2021.
Zehao Xiao, Jiayi Shen, Xiantong Zhen, Ling Shao, and Cees M Snoek. A bit more bayesian: learning with uncertainty. In International Conference on Machine Learning.
PMLR, 2021.
Shanshan Zhao, Mingming Gong, Tongliang Liu, Huan Fu, and Dacheng Tao. Domain generalization via entropy regularization. In Advances in Neural Information Processing Systems, volume 33, 2020.
Kaiyang Zhou, Yongxin Yang, Timothy Hospedales, and Tao Xiang. Learning to generate novel domains for domain generalization. In European Conference Computer Vision, pp. 561-578, 2020a.
Kaiyang Zhou, Yongxin Yang, Yu Qiao, and Tao Xiang. Domain generalization with mixstyle. In International Conference on Learning Representations, 2020b.
Kaiyang Zhou, Ziwei Liu, Yu Qiao, Tao Xiang, and Chen Change Loy. Domain generalization: survey. arXiv preprint arXiv: arXiv:2103.0220 103.02033, 2021.
13

---

Published as a conference paper at ICLR 2022
A DERIVATIONS
Derivation of variational domain generalization In domain generalization, since the target domain data is inaccessible, the distribution p(0,17) is intractable. We leverage the meta-learning setting to mimic the domain generalization process. particular, we episodically divide the source domains into meta-source domains S' and meta-target domain T' and learn the abiliit to generalize to the target data. Thus, during training, wc generate the parameter distribution by the meta-source data S' to approximate the distribution p(O, (T') generated by the meta-target data. Then at inference, the model is able to approximate the distribution p(O,|T (7) with the parameters generated by the source data S. To do so, introduce variational distribution ((pr1S'))
approximate the true posterior over the model parameter 0. The full derivation of eq. (2) in the main paper is as follows:
logp(ye [x,, T log / plye xv 0r (0. (T)dd
log plyelxe, 02) p(0 IT)
q ( (')d
(oooorss) [p(ye] /x,, 0.)) pl or (T))
(8)
=
log
(0v St)
log [plye Xv 0w) pl0. (T)
2 Eg(0
a(u (S')
=
Xx, 0r)) /x,,
Derivation of single sample generalization Since there is little information available about the target domain target data in the variational distribution q (0, in eq. (2), the resultant model not adaptive to the target domain data. To generate a model adapted to the target sample, we introduce information of the target data, and incorporate the meta-target sample x into the variational distribution g00r Ixe, S*). The detailed derivation is:
log plye Xg, T log / plyr|xe,0r On (
p(O..T)
log plyrixe,00 02) 0 , S')
(0x Xr. S')d0
p(O,(TT')
log
[yl0. [p(ye Xx 0.)
8 O0 Xr, 8¹)
pl (T)
2 Ey(O, x S') log [p(ye Xr. 0.)
q | 8')
= E, x ST) plye /x, 0r)] - D DKL[g (9(
xv.
Comparison of the two evidence lower bounds The main difference between eq. (8) and eq. (9) the variational posterior (.r)). Compared with eq. (8), our method (eq. introduces the target sample Xy into the generation of the variational posterior, which therefore achieves more adaptive classifiers for the target sample. Moreover, the tightness the bound is also related the variational posterior. The approximation gap between our bound (eq. 3) and the objective log-likelihodd corresponds to the KL divergence between the variational posterior (xe, S') and the true posterior p(0, Xe,, Ye,, T'), as shown in the following equation:
logplyel Xe., T') Rete. O+) - DKKI. (arlg (000:larrSS)|ll0001111 S')ll((O,:IT')
ELBO
(10)
+ [Kr./g(Op S')l, p .e. T
Approzimation Gap
Compared with eq. (2), whose approximation gap is formulated as DKt. (s)) (0o00////..a yr. yr) method takes the given sample x, as of the conditions, leading tighter lower bound.
14

---

Published as a conference paper at ICLR 2022
B ALGORITHM OF SINGLE SAMPLE GENERALIZATION
We describe the the detailed training and test algorithm of our single sample generalization method in Algorithm
Algorithm 1 Single-Test Test- -aeese Generalization
TRAINING TIME
==1 each with a sample pairs (x.. Require: Learning rate X; the number of iterations Nater.
Require: Source domains S = [D.).z]
Initialize + = {Φ, 0u, +b) Φ: IaaeeNtt-pretraing feature extractor; ah: multiple layer module.
for iter in Niter do
T - Randomly Da f= t');
S' < [D.] I': (6) (6))) ~ T' Sample datapoints {(x, .Ye
W (m)) (m) fo. (T'); w(") N(u (r)n (om)) I/ Compute meta-prior p(we|T") as cq.(6)
( Hw,rsow = (S'')) wa NHww, (ww,) ). Compute p(w,. (S") in cq.(4)
we
P w (n) (n) fo. (w obxx )); w!" NN o (n) Compute q( (wwr (x(
(,,))))) ,5)) e5.
C Σ CrossEntropy ((w!r) (m)) ((xx 1),
CrossEntropy (ww)") ),))), (())
+ ( (x) S')]lp(w, If Compute loss as cq.(7)
Update parameters: O @ AVaL. // Gradient descent step end for
TEST TIME
Require: Source domains {D,) target samples {xx)?== from the target domain T: trained model with weight @ = { On, 26)
Mw Tw. = (S); w. ~ N N(twa, ow.). ). Compute p(w.(S)
(w("), (!)) = Soal (Ws, ((xx))(x w( ~ N (o)) (0), (
(. // Compute <(welx!")
return Ye w(
C DATASETS AND IMPLEMENTATION DETAILS
Datasets PACS (Li et al., 2017) is a widely used dataset consisting of 9,991 images of seven classes from four domains, i.e., photo, art-painting, cartoon and sketch. We use the same training and validation split as in (Li et al., 2017) and follow the "Icave-one-out" protocol from (Li et al., 2017; 2019; Carlucci et al., 2019). Office-Home (Venkateswara et al., 2017) has 15,500 images of 65 categories. The images are also from four domains, i.e., art, clipart, product and real-world. We use the same experimental protocol as for PACS. Rotated MNIST and Fashion-MNIST are utilized in Piratla et al. (2020). We follow their recommended settings and randomly select a subset of 2,000 images from MNIST and 10,000 images from Fashion Fashion-MNIST. The subset of images rotated by 0" through 90 in intervals of 15, creating seven domains. We use the subsets with rotation angles from 15t to 75% as the source domains, and images rotated by 0" and 90º as the target domains. For comparison, we evaluate our method on both in-distribution and outto--distribution data.
Implementation details We evaluate our method on PACS with both ResNet- 8 and ResNet-50 (He al., 2016) pretrained on ImageNet (Deng et al., 2009) as the backbone. During training, we use Adam optimization and train the model for 10,000 iterations. The learning rate of the backbone set to 0.00005 for ResNet- 18 and 0.00001 for ResNet-50, while the learning rate of the network for generating the classifier is set to 0.0001 consistently. The batch size is 128. To generate the classifier, in each iteration we select 10 samples from each category in each meta-source domain for generating the center features S', and the same number of samples from the meta-target domain for T'. The model with the highest validation accuracy is utilized for evaluation on the target domain. Most of office-Home are the same as PACS. Since there
the experimental settings and hyperparameters are more categories in Office-Home the number of samples per category per domain is set to 5 to fit the memory footprint. The learning rate of the backbone is set to 0.00001 for both ResNet-18
15

---

Published as a conference paper at ICLR 2022
Table Implementation details of our method per dataset and backbone. "Number of source samples" denotes the number of samples per class per source domain for generating the adapted classifier.
Dataset
Backhone
Classifier learning rate Backhone learning rate Number of source samples
ResNet-18
0.0001
0.00005
10
PACS
ResNet-50
0.0001
0.00001
10
ResNet-18
0.0001
0.00001
Office-Hooee Home
ResNet-50
0.0001
0.00001
Rotated MNIST
ResNet-18
0.0001
0.00005
10
Fashion-MNIST
ResNet-18
0.0001
0.00005
10
Table 8: Comparison on PACS. Our method achieves best mean accuracy with a ResNet-50 backbone and is competitive with ResNet-18 18. Notably, it surpasses the adaptive test-time methods by Wang et al. (2021) and Dubey et al. (2021), despite them using more data at test-time (see Table 1). denotes the reimplemented results in both this table and Table 9.
Backhone
Method
Art-painting
Cartoon
Carlucci et al. (2019)
96.03
79.42
75.25
71.35
80.51
Dou et al. (2019)
94.99
80.29
77.17
71.69
81.04
Zhao et (2020)
96.65
80.70
76.40
71.77
81.46
ResNet-18
Zhou (2020s)
96.20
83.30
78.20
73.60
82.83
Wang al. (2021)*
95.49 #027
81.55 =0.35
77.67
77.64 #0.27
83.09 20.13
Zhou et al. (2020b)
96.10
84,10
78.80
75.90
83,70
Seo al. (2020)
95.87
84.67
77.65
82.23
85.11
This paper
95.87 #0.44
82.02
79.73
78.96 #0.67
84,15 0.21
Dou et al. (2019)
95.01
82.89
80.49
72.29
82.67
Dubey al. (2021)
Zhou et (2020a)*
97.55
85,21
80.33
76.53
84,90
ResNet-S5 50
Zhao et al. (2020)
98.25
87.51
79.31
76.30
85,34
Gulrajani & &LL.n Lopez Par (2020)
97.20
84,70
80.80
79.30
85,50
Wang al. (2021))
86.30 20.36
1::00
78. 20073
1:0
Seo al. (2020)
95.99
87.04
80.62
82.90
86.64
This paper
97.88 #:.15
88.09
=0.26
83.83
#:0668
80.21
#0.66
87.51
=:022
and ResNet-50. For fair comparisons, we evaluate the rotated MNIST and Fashion-MNIST with ResNet- 18, following (Piratla et al., 2020). The other experimental settings are also the same as PACS. We train all models on an NVIDIA Tesla V100 GPU. The detailed information about other hyperparameters are summarized in Table 7.
D EXTRA EXPERIMENTS
D.1 DETAILED COMPARISONS WITH STATE OF THE ART
PACS In Table 8, we conduct experiments with both ResNet-18 and ResNet-50 backbones. Our method achieves good performance using the ResNet-18 backbone. For each individual domain, we are competitive with the state of the art and slightly better on the "cartoon" domain when using ResNet-18 18. On the "art-painting" and "cartoon" domains with ResNet-50, our method also achieves good performance. Although it delivers competitive, sometimes even better, performance on most domains, our method is not as good on the "sketch" domain. One reason might be that images and features from this domain carry less information than other domains, leading to less adaptive models.
Office-Home As shown in Table 9, our method again achieves good overall performance with both the ResNet-18 18 and ResNet-50 backbones. With ResNet-18 as the backbone, outperform other methods by a good margin on the "clipart" domain, while delivering competitive performance on the other domains. When utilizing ResNet-50 the backbone, method achieves good performance on all four domains.
Rotated MNIST and Fashion-MNIST On rotated MNIST and Fashion-MNIST. for fair comparison, we use ResNet- 18 as the backbone following (Piratla et al., 2020) and evaluate the method on both in-distribution and out-of-distribution sets. Our method achieves best performance both datasets as
16

---

Published as a conference paper at ICLR 2022
Table Comparison on Office-Home. Our method achieves the best mean accuracy using both ResNet-18 18 and ResNet-50 backbone. Notably, it surpasses the adaptive test-time methods by Wang al. (2021) and Dubey et al. (2021), despite them using more data test-time (see Table 1).
Backbone
Method
Ait
Clipart
Product
Real World Mean
Carlucci et al. (2019)
53.04
47.51
71.47
72.79
61.20
Seo et al. (2020)
59.37
45,70
71.84
74.68
62.90
ResNet-18
Huang et al. (2020)
58.42
47.90
71.63
74.54
63.12
Wang et al. (2021))
56.45 au30
52.06
2018
73.19 10.42
74.82 2:277
64,13 20116
Zhou al. (2020a)
60.60
50.10
74.80
77.00
65.63
This paper
4:
53,94 20:45
76.07 1:
20.2
Gulrajani & Lopez-Puz (2020)
61.30
$2.40
75.80
76.60
66.50
Zhou al. (2020a)
63.62
51.48
76.57
78.95
67.66
ResNet-50
Wang et al. (2021))
62.12 #033
56.65 $0.49
75.61
#0.57
77.58 #:042
67.99 =:022
Dubey et al. (2021)
68, 68,90
Sun Saenko (2016)
54,40
76.50
78.40
68870
This paper
67.21 #0.50
57.97 20.37
78.61
80.47 1:0.1
71.07 +:031
Table 10: Comparison rotated MNIST and Fashion-MNIST. In-distribution performance is evaluated on the test sets of MNIST and Pashion-MNIST with rotation angles of , 30%, 45", 60 and 75,, while the out-of-distribution performance is evaluated test sets with angles of 09 and 90% We achieve the best performance on both the in-distribution and out-of-distribution test sets.
MNIST
Mishion-MNIST
In-distribution
In-distribution -uittf-diittibutton
Dou et al. (2019)
98.2
93.2
86.9
72.4
Piratla al. (2020)
98.4
94.7
89.7
78.0
This paper
98.9 #0.1
95.8 #0.1
90.9 #02
80.8
1:0.5
shown in Table 10, especially for the out-of-distribution setting. Moreover, method demonstrates less performance drop from in-distribution to -uttof-distribution data comparison to other methods.
D.2 SINGLE SOURCE DOMAIN GENERALIZATION
As our method learns the adaptation ability by mimicking the domain shift during training, requires at least two source domains to support the meta-learning scheme, which is a limitation of the method.
We conduct an experiment that uses SVHN as the single source domain and MNIST as the target. We generate source domains by two simple methods: random image split and clustering of images (K-means). The results Table 11 show that our method performs slightly better with larger domain shift simulated in the single source domain. To learn better adaptation ability, auxiliary methods are needed to generate larger domain shifts, for example by domain augmentation techniques like Qiao et al. (2020).
E VISUALIZATIONS
More comparisons with baseline To further demonstrate the effecctiveness of our method, provide more visualizations of the classifier parameters and feature representations from different domains in Figure. 6. The left column shows the visualizations of the "variational amortized classifier" (baseline), and the three columns on the right show our results. The same conclusion can be drawn here in the main paper. Our method is able generate adapted classifiers for each test sample, providing better predictions than the fixed classifiers in the baseline method.
Failure cases To gain insights into our method, we also provide some failure cases in Figure 7. Our method gets confused when samples have objects of different categories in the same image, as shown in the first row. Although failing in these cases, our model provides correct predictions for the other objects in the image. In the visualizations, the classifier with the same category of the labeled object is also close to the feature, which demonstrates the effectiveness our method. In the middle two rows, method struggles with the samples that contain multiple objects complex backgrounds.
17

---

Published as a conference paper at ICLR 2022
Table 11: Experiments on single source domain generalization. We use SVHN as the source domain and MNIST as the target. Our method performs slightly better with larger domain shift simulated in single source domain.
Method
SVHN MNIST
Baseline
82.05 10.34
Random split by images Split by cluster
82.45 10.70
83.01 #0.36
Baseline
Single sample generalization
Photo
dog sample
A giraffe sample
horse sample
Art-painting
dog sample
horse sample
sample
Cartoon
An elophant sample
giraffe sample
person sample
Sketch
guitor sample
An elephont sample
house sample
Classifiers:
Elephant
Dog
Girafte
Guitar
Horse
House
Person
Figure 6: Visualization of single sample generalization on PACS. We plot the test samples and classifiers the same 2D plane. Different shapes denote different categories. Samples are red, classifiers in blue. The baseline method produces the same classifier for all samples from each domain, while our method generates classifier adapted to each target sample. The two methods the same test samples from each domain. The test sample is shown in the left-top corner of each figufigure. The visualization shows why our model performs better.
possible reason is that take full advantage of the given sample, we utilize multi-level features of the target sample to generate the adapted classifier. However, the complex background and multiple objects in the image bring too much noisy information, leading to less adapted classifiers for the given sample. A solution can be extracting information of the target sample selectively to reduce noise in the features. Moreover, in the "sketch" domain, as shown in the last row, the samples usually have less information than other domains. This makes method more sensitive to the given information. When there is noisy information. e.g., the chair the left figure, or object with unobvious features, e.g., the elephant in the right figure, the method fails to generate proper classifiers for the sample.
18

---

Published as a conference paper at ICLR 2022
Prediction: Person
Dog
Elephant
Prediction: Ginffle
Prediction: Horse
Label:
Prediction: Dog
Prediction: Dog
Pemon
Ellphant
Prediction: Hlephant
Prediction: Horse
Classifiers:
Elephant
Dog
Giraffe
Guitar
House
Figure 7: Failure case visualizations of our method. The visualization settings are the same as Figure 6. Our method makes wrong predictions, be that the correct classifiers are also close to the samples, which shows that the classifiers generated by our method are still adapted to the given sample these cases.
F MORE COMPARISONS WITH TENT
We provide more detailed comparisons with Tent Wang et al. (2021) in Figure to further show the effectiveness of our method. The three rows in Figure 8 show the accuracy of different settings 0%. 45", and 90º target domain, respectively. The mean accuracy is shown Figure in the main paper. The same in the main paper, the left column shows results under the "single target domain" setting, while the right column shows the "multiple target domains" setting. In the "single target domain" setting, Tent is utilized adapt the base model trained source domains to each target domain independently. By contrast, in the "multiple target domains" setting, the base model is adapted and evaluated on three target domains jointly. without the domain identifiers. The base model adapted by Tent using different number of samples, e.g., 1, 32, 128, with different optimization steps, e.g., 10, 100. The same conclusion can be drawn here as the main paper. Compared with Tent, our method adapts the model to each target sample individually by single and efficient feed-forward pass. Thus, our performance is independent to the settings and optimization steps.
Specifically, as shown in the left column, Tent achieves better performance with both larger numbers of samples and fine-tuning steps, especially on 0" and 90º domains. However, with fewer target samples being available, and ultimately just sample, the adaptation of Tent starts suffer. or even hurt the accuracy with more optimization steps. When adapted to three target domains jointly, shown in the right column, the adapted performance is similar with the "single target domain"
19

---

Published as a conference paper at ICLR 2022
Single target domain
Multiple target domains
96.5
96.0
Accuracy
0
93.5
16
32
128
64
128
Number of samples
Number samples
99.2
99.2
99.0
99.0
98.8
98.8
08.6
98.6
Accuracy
Accuracy
45
90.2
90.2
98.0
98.0
97.8
97.8
97.6
97.6
Number samples
Number samples
95.5
95.5
95.0
95.0
Accuracy
Accuracy
94.0
94.0
90
93.5
93.5
Bose Model
93.0
Single sample generalization
93.0
Tent (1 step)
(10 steps)
Tent (100 steps)
92.0
92.0
Number samples
Number samples
Figure 8: Single sample generalization vs. Tent for different settings rotated-MNNST. Tent shows good performance with a large batch of samples from a single domain (left). When provided only one sample or when given samples from different domains, without their domain id (right), Tent suffers. In contrast, our method is independent to the number of target samples and domains.
settings with few target samples. With more target samples, the performance degrades, worse than the left column. Accuracy on 09 domain improves slightly, while 45 and 90º domain drops as the adaptation affected by samples from other domains. In contrast, since our method adapts the model each target sample indivicually, achieve consistently good performance regardless of how many domains the test samples cover. This demonstrates the benefit of our single sample generalization.
20


Reviews:
[{"review_id": "yBPrYAA4dTp", "reviewer": "Reviewer_6n8V", "summary": "", "questions": "", "limitations": "", "rating": 5, "confidence": 3, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "Strength:\n* The paper proposes to use meta-learning scheme to do one-shot learning. The idea is heuristic to the research community\n* The paper provides several empirical study and analysis to demonstrate the performance of the proposed approach\n* the proposed method can benefit real application scenario of extreme few shot cases\n\n\nWeakness:\n* It is unclear how training on each instance of the source domain would enable a large enough domain shift to benefit a larger domain shift encountered during test time. \n* even though most experiments in the paper are considering multi-source domain adaptation. It is unclear why not testing on the single-source setting, since training the proposed method does not require multiple source domains\n* It seems that the proposed method underperforms the method proposed by Zhou et al. (2020a)  in all of the Resnet-18 experiments. and For some reason, for all Resnet-50 Experiments only for this baseline method is not conducted\n* it would be helpful to show how an ablation study on how exactly the proposed meta-learning scheme improves performance vs non-meta-learning based one-shoot learning, such as [1, 2], \n\n[1] Luo, Yawei and Liu, Ping and Guan, Tao and Yu, Junqing and Yang, Yi. Adversarial Style Mining for One-Shot Unsupervised Domain Adaptation. Advances in Neural Information Processing Systems, 2020. \n\n[2] Dong, Nanqing and Eric P. Xing. Domain adaption in one-shot learning. Joint European Conference on Machine Learning and Knowledge Discovery in Databases, 2018. 573--588. ", "summary_of_the_paper": "The authors propose to learn to generalize across different target domains with single samples by using a meta-learning paradigm. Specifically, during training, the course domains are divided into several meta-source domains and meta-target domains to explore the adaptivity of the model by incorporating information of the meta-target sampling when learning the model parameters. ", "summary_of_the_review": "As the discussed above, due to weak performance, and lack of more empirical demonstration of the proposed method. I recommend marginal reject on this paper. I would like to adjust my rating after discussing with other reviewers and AC", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "", "extra_scores": {"correctness": "4: All of the claims and statements are well-supported and correct.", "technical_novelty_and_significance": "3: The contributions are significant and somewhat new. Aspects of the contributions exist in prior work.", "empirical_novelty_and_significance": "2: The contributions are only marginally significant or novel."}, "extra_text": {}}, {"review_id": "UYyEpkx0Bn2", "reviewer": "Reviewer_xA1m", "summary": "", "questions": "", "limitations": "", "rating": 5, "confidence": 3, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "- (+) Interesting setting that has not received much attention: test-time adaptation from a *single* test example.\n- (-) However, there is little intuition given why test-time adaptation using a *single* example makes sense. It's not clear why this should work, unlike adaptation using a batch of examples, which makes much more sense intuitively (to me, at least).\n- (+) Elegant formulation of the method as variational Bayesian inference.\n- (+) Computationally-efficient method: a single forward pass necessary to adapt the model\n- (-) I'm not sure the method is really an instance of \"meta-learning\" (as in \"learning to learn\"). I understand that the method is simply mimicking the adaptation process at training time so as to optimize the parameters of the adaptation process.\n- (-) There is little analysis of the results to show why the method performs quantitatively so well. It's difficult for me to intuitively grasp why adaptation using a single test example outperforms methods that also use other test examples from the same domain (Wang et al. 2021, Dubey et al. 2021).\n\nAdditional advice to improve the paper.\n\n- Illustrating figures (as early as the introduction) would be helpful to convey more efficiently the gist of the method, and the motivation for the setting (as mentioned above, it's not clear to me why adaptation to a single example makes sense).\n- Additional possible reference of a method for test-time adaptation: [Learning to Generalize One Sample at a Time with Self-Supervision](https://arxiv.org/abs/1910.03915)", "summary_of_the_paper": "- The paper describes a method for domain generalization that performs test-time adaptation using a single test example at a time (as opposed to a transductive setting used in other works where a whole batch of test examples are used).\n- The method is cast as a meta learning task. The training data is split into meta-training/test domains to mimic the adaptation process during training.", "summary_of_the_review": "Preliminary recommendation: unsure. The paper describes an elegant method with good empirical performance, but it does not provide intuition/theoretical explanations/empirical analysis why it should/does work. I feel that this paper brings little new scientific knowledge that future research could build on, hence its impact may be limited.\n\nRequests/questions to the authors.\n- Please address the negative points raised above.\n- How are the source/target domains generated during training ? I understand they are generated at random, but since you have multiple domains in the datasets used (say, PACS) I imagine you do use the annotations of these domains at some point ?\n\n---\n**Final summary after discussion with other reviewers**\n\nI am fine seeing this paper accepted given that this is the advice of the other reviewers. However I still see important weaknesses in this paper that the authors may want to fix in the final version and/or in future work.\n\n1. There is no intuitive or strong theoretical support for adaptation from a single test example. The proposed method does produce non-trivial empirical results that means that it must rely on specific information/assumptions, which are not made clear. The reason it matters is that these assumptions must have limits of applicability. These **limitations** should be explored, discussed, or at the very least acknowledged in the paper. My impression is that the variational and meta learning aspects of the proposed implementation are eclipsing the more fundamental points on which the method relies.\n\n\n2. The authors responded to the lack of **illustrations** by including fig. 1/2 but I don't find these satisfatory. Figure 1 provides almost no information regarding (1) above. As for Figure 2, it's not even clear what it represents (\"architecture of our method\"). Training time ? Test time ? The boxes are a mix of operations/layers, variables, and distributions. The colors are not defined. Etc.\n\n\n3. I still think that calling of the approach \"**meta learning**\" is a stretch. Another reviewer made me realize that there is a precedent in the literature for using the term when merely mimicking the adaptation at training time, but I'm not sure that perpetuating a bad choice is a valid reason.", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "", "extra_scores": {"correctness": "3: Some of the paper’s claims have minor issues. A few statements are not well-supported, or require small changes to be made correct.", "technical_novelty_and_significance": "3: The contributions are significant and somewhat new. Aspects of the contributions exist in prior work.", "empirical_novelty_and_significance": "3: The contributions are significant and somewhat new. Aspects of the contributions exist in prior work."}, "extra_text": {}}, {"review_id": "F8AUh_phe0z", "reviewer": "Reviewer_dNDg", "summary": "", "questions": "", "limitations": "", "rating": 8, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "Pros. \n\n1. The proposed method is more flexible than the previous generalization- and adaptation-based methods. Compared to generalization-based methods, the model can better adapt to target domains via conditional generated parameters. Compared to previous adaptation-based methods, the proposed method does not rely on batches of samples from the target domain with extra fine-tuning operations or extra networks.\n\n2. The paper systematically summarizes previous related works including domain adaptation/generalization, domain meta-learning, and test-time adaptation. Table 1 clearly shows the difference between this work and previous works in terms of training and test-time settings. \n\nCons.\n\n1. The proposed method requires multiple source domains during training to support the meta-learning scheme. However, previous test-time adaptation models do not have such limitations and can be trained on one single domain. How to guarantee fairness in comparison to previous test-time adaptation methods? What is the minimal number of source domains required for training?\n\n2. During training, the paper proposed to approximate the model function with the accessible source data by the variational inference. Is there any underlying assumption about the distribution similarity between the source and target domain? Can the \"adaptivity gap\" still be minimized when the target domain is significantly different from the source? \n\n3. The paper proposed to construct an adapted classifier during inference. As indicated in the main paper, \"both the meta-prior distribution and the variational posterior distribution of the classifier are generated by amortized inference using the amortization technique\", but why the amortized inference is applied?  More elaboration is required to justify the motivation.\n", "summary_of_the_paper": "This paper studied the problem of single test sample generalization. Its goal is to adapt a pre-trained model to unseen target domains without extra fine-tuning. The paper formulated the single test sample generalization problem as a variational inference problem and proposed a meta-learning framework. To bypass extra fine-tuning, a single test sample was used as a conditional to generate model parameters. Experiments and ablation studies on common-used benchmarks demonstrate the effectiveness of the proposed method. ", "summary_of_the_review": "This paper addressed \"single test sample generalization\", which is an interesting and important problem in the field of domain generalization. The method is technically sound and novel. Although I have some concerns regards the method and experiments as indicated in the main review, I overall remain positive towards this paper. I hope the authors can address my concerns in the rebuttal.\n\nAfter rebuttal: I have read the response and comments of other reviewers. All of my concerns have been addressed in the response. I recommend acceptance for this paper. I highly suggest that the authors should widely discuss the remaining weaknesses raised by the reviewers in the final version.", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "", "extra_scores": {"correctness": "3: Some of the paper’s claims have minor issues. A few statements are not well-supported, or require small changes to be made correct.", "technical_novelty_and_significance": "3: The contributions are significant and somewhat new. Aspects of the contributions exist in prior work.", "empirical_novelty_and_significance": "2: The contributions are only marginally significant or novel."}, "extra_text": {}}, {"review_id": "Do3eVlzReAr", "reviewer": "Reviewer_wnp4", "summary": "", "questions": "", "limitations": "", "rating": 8, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "I will now highlight the strengths and weaknesses of the paper.\n\n**Strengths**\n\n1. The paper is generally well-written and easy to follow. With the exception of a few minor points raised under weaknesses, the authors generally do a good job of situating the problem setup and motivating the proposed approach. I particularly appreciate how the authors build up from the most rudimentary version of the proposed approach to adding more relevant terms to the objective that might further improve out-of-domain performance. Furthermore, in this space of test-time adaptation, when compared to prior work which either rely on single or multiple passes over the entirety of target data, I think the paper is trying to address a relatively realistic and timely problem setting that the community might find useful.\n\n2. Unlike prior test-time adaptation approaches, I think a big positive point in support of the proposed approach is that it doesn’t require — (1) fine-tuning on target data, (2) more than a few target samples, and still ends up either being competitive or outperforming the same. Obtaining an adapted model on target data based on a single or few source samples with a single forward pass offers significant benefits in terms of data and computational constraints.\n\n3. Out-of-domain generalization results obtained via the proposed approach seem to demonstrate the utility of the same (although marginally in some cases). Further ablations on rotated-MNIST highlight the stability and utility of the same when compared to TENT. Additionally, I like that the authors' highlight failure cases of the proposed approach accompanied with hypotheses surrounding things that fail on particular samples.\n\n**Weaknesses**\n\n1. If I understand correctly, one of the crucial bits the proposed approach relies on during training is the availability of domain labels on source data — source instances belong to different domains because the domain labels say so, which in turn influences how the meta-source and meta-target splits are constructed (also noted under conclusions in the submission). While this is a perfectly fine assumption, the paper would benefit if the authors included an experiment validating the extent to which the proposed approach relies on this. Essentially, a setting where the source domain labels are randomized — as in, (say) if there are 3 source domains, data at training time is grouped randomly into 3 groups instead of by domain and meta-source & meta-target splits are constructed based on these three groups. Considering such a setting would highlight how important mimicking the domain shift within a source is important. If the out-of-domain obtained results are worse, then there is additional validation that constructing appropriate meta-source & meta-target shifts matters. If not, then the utility of the proposed approach lies somewhere else. I would encourage the authors to include such an experiment.\n\n2. [Minor Points] Including the model architecture diagram from the appendix to the main paper would make it easier for the reader to follow the supporting description in Section 3  (page 5) and under implementation details. While I understand the need to include the target sample in the variational posterior (as considered in equation 3), I don’t completely follow the supporting justification (on page 4, the paragraph above “single-test sample generalization”) in terms of the adaptivity gap. Adaptivity gap (as discussed in Dubey et al. 2021) is a general statement about DG settings. I’m not entirely certain what extra insights it provides in the supporting justification. When finally evaluating on target data, is an adapted model obtained for every target sample, or is it the case that it is obtained from a few samples. If it’s the latter, how are these target samples chosen? ", "summary_of_the_paper": "The paper proposes an approach to ensure a model trained on a set of source domains generalizes well to an unseen target domain based on a single unlabeled target sample. Unlike the standard domain generalization (DG) setting, where there is no scope for adaptation in the target domain, and domain adaptation (DA), where the model has access to source and unlabeled target data during training, the paper falls somewhere in between where no access to target data is assumed during training and a single unlabeled target sample is allowed for quick adaptation. In principle, the proposed setting is somewhat similar to source-free domain adaptation with the distinction that only one sample (and not the entire target dataset) and one quick adaptation pass on the data is allowed. The authors leverage a meta-learning paradigm to mimic domain shift by defining meta-source and meta-target domains within the source domain vocabulary (has also been considered in prior DG settings). The approach adopted by the authors relies on modeling a conditional distribution over the model parameters given a meta-target domain sample and source domain representative features. The authors set this up within a variational inference framework that allows them to explicitly parameterize this conditional distribution to infer model parameters in a target domain. The authors further explore the utility of different instantiations and alternative formulations of their objective and show that their proposed version has the best performance. When compared with prior DG and test-time adaptive methods, the proposed approach leads to competitive or improved performance. Further ablations demonstrate the utility of the proposed approach over other test-time adaptive approaches in terms of number of target samples available for unsupervised adaptation.", "summary_of_the_review": "The points highlighted under strengths and weaknesses form the basis of my rating. I am generally supportive of the paper and think that it addresses the test-time adaptation problem from a relatively constrained yet realistic standpoint. The paper is well-written and generally easy to follow. The most positive bit in support of the paper in my opinion is the lack of reliance on the entirety of target data or multiple passes on the same to adapt a model. Regarding weaknesses, since the paper relies heavily on the meta-source and meta-target split construction, I think it’s important to address the extent to which this reliance is true (in accordance with the suggested experiments in 1). The minor points in 2 are addressable, I think.\n\n**Thoughts post author responses**\n\nAs stated in my follow-up reply to the authors, I think my primary concerns regarding domain-split construction were sufficiently addressed by the authors. Similar concerns were also shared by other reviewers and the authors provided sufficient experimental evidence to address the same. Additionally, concerns surrounding results with different backbones have also been sufficiently addressed (in my opinion) by the new experimental results. Given these and the fact that the paper makes an interesting contribution and studies a timely experimental setting, I continue to recommend acceptance of the paper (and would like to stick to my original rating).", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "", "extra_scores": {"correctness": "4: All of the claims and statements are well-supported and correct.", "technical_novelty_and_significance": "3: The contributions are significant and somewhat new. Aspects of the contributions exist in prior work.", "empirical_novelty_and_significance": "3: The contributions are significant and somewhat new. Aspects of the contributions exist in prior work."}, "extra_text": {}}, {"review_id": "5hrFoDlhQI", "reviewer": "Reviewer_n6z3", "summary": "", "questions": "", "limitations": "", "rating": 8, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "# Strengths\n1. The idea of artificially creating meta-source and meta-target domain within the source domain is interesting.  This exposes the classifier to the notion of distribution shift and the learnt abilities of the model to handle such distribution shifts are shown to transfer to the unseen target domain.\n2. The problem an interesting angle for viewing domain generalization. The key question of \"how to expose models to distribution shift\" when no target samples are available, is an interesting one.\n\n# Weaknesses\n1. It is not clear why a random division of source $\\mathcal{S}$ into $\\mathcal{S}^\\prime$ and $\\mathcal{T}^\\prime$ will always simulate distribution shift. Does a more sophisticated division (perhaps using clustering or some notion of feature distance) make more sense to create $\\mathcal{S}^\\prime$ and $\\mathcal{T}^\\prime$?   The distribution shift between meta-source and meta-target has not been quantified or even visualized.  This limits the modification of this idea to other tasks since _why a random split works_  isn't clear.\n2. While the multi-source domain generalization setting has been explored, it is not clear to me whether the same approach will apply to cases where only one source is available (for instance SVHN as source and MNIST/USPS/... as target, as shown by TENT (Wang et al. )).  Domain generalization is largely an unsolved problem in the digits classification task -- which is considered a trivial task in terms of in-domain accuracy (near-100% performance on MNIST).  It is unclear to me how the proposed approach would be able to simulate a meta-source and meta-target if the source is a largely homogenous dataset such as MNIST.\n3. It is stated in the introduction that existing test-time adaptation methods such as TENT perform finetuning, while this method does not.  Unless I am mistaken, model parameters are updated for every new test sample even in this method (please correct me if I'm wrong).  So how is it not finetuning?  Sure, additional networks or proxy self-supervision tasks are not used (like in TTT), but there does seem to be adaptation at test time.\n\n# Questions\n1. In the PACS experiments (Table 3), the method surpasses prior art with ResNet50, but not with ResNet18. What might be the reason for this?\n2. In Figure 2 (and similar figures in the Appendix) I don't understand the underlying space of the visualization.  How is a classifier and a test sample visualized in the same space? Or does the blue symbol indicate the subspace which the classifier predicts as the respective classes? Please provide details of how this visualization is computed.  \n\n# Feedback \n- On page 1, existing test-time-training methods mentioned (Sun et al, Wang et al) are mentioned, with the statement that \"these methods typically rely on batches of samples from the target domain\".  This is not entirely true\n    - TTT (Sun et al.) have two variants of their method, one which operates on a single sample, and an online method that uses a batch of training samples.\n    - There is also a recent method in NLP (Banerjee et al. NAACL 2021 https://arxiv.org/abs/2103.11263 which is largely inspired from TTT) that makes predictions on single test instances.\n- Table 1 is useful for understanding how this work differs from prior art.  However TTT (Sun et al.) isn't listed here -- it should be listed as a method that uses single samples $x_t$  and performs fine-tuning/adapting.\n- Table 1 could also include a column that states whether extra networks / models are needed.\n- The model architecture figure from supplementary material should be moved to the main paper.\n- I would also recommend adding an algorithm / pseducode to complement the equations in Section 3. The methods section is more than 2 pages long, and not having a succinct pseudocode hampers the readability of this paper.\n- Related to my statement in Strengths #2, a recent paper approaches this problem by proposing a data augmentation method that exposes classifiers to \"novel views\" of a source image: see Chai et al. CVPR 2021 https://arxiv.org/abs/2104.14551 . However, they target adversarial robustness (and do not have results on DG benchmarks).  It might be interesting to compare their method of test-time data augmentation, with your method of test-time variational inference, in related work.\n\n# Review Summary\nThe idea is interesting and the paper is well-structured in general.  However there are a few confusing aspects that I have pointed out as well as some inconsistencies with the claims in the paper.  That being said, the empirical results suggest that this method is superior to TTT, TENT and other baselines on benchmarks used in this paper.  I am giving a weak reject at this point, but will be happy to receive clarification from the authors before the final decision.\n\n## update after discussion period\nThe authors have sufficiently addressed concerns raised by me and other reviewers and new experiments / analyses / comparisons have strengthened the paper.  After these changes, I am increasing my rating to \"accept\".\n", "summary_of_the_paper": "The paper deals with the problem of domain generalization, specifically performing inference on a single test example.  The key idea is to use meta-learning to train the model on the source data -- in the training stage, the source data is divided into meta-source and meta-target, and the model is trained to adapt to the meta-target domain.  This mimics domain shift within the source data.  The method is seamlessly transferred to the target domain, where inference is performed on a single test example, without finetuning model parameters or using additional networks. ", "summary_of_the_review": "interesting idea, but confusing/inconsistent claims; unclear why a random split of source into meta-source and meta-target would create a distribution shift.", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "", "extra_scores": {"correctness": "3: Some of the paper’s claims have minor issues. A few statements are not well-supported, or require small changes to be made correct.", "technical_novelty_and_significance": "2: The contributions are only marginally significant or novel.", "empirical_novelty_and_significance": "2: The contributions are only marginally significant or novel."}, "extra_text": {}}]

Author rebuttal:

Meta-review: This paper proposes a new method for domain generalization by adopting a single test example. Authors formulate the problem using a variational bayesian framework which ends up in an adaptation technique requiring a single feed-forward computation. The provided empirical results indicate that the proposed method has comparable performance to techniques which require more data.

Reviewers all acknowledge the novelty and significance of this work. The paper is well-written and the related work is adequately discussed. Moreover, the proposed method is computationally efficient and empirical results provide strong evidence in its favor. While I am recommending acceptance, I tend to agree with reviewer xA1m about the main weaknesses of this work and I recommend authors to improve them for the final version:

- Lack of proper discussion or intuition about under what conditions the proposed method works well. This may be using theoretical analysis, using toy examples, trying to break the method, motivate using prior work or just simply providing intuitive arguments. Also, as reviewers pointed, Figure 1 is currently very confusing.
- Lack of analysis or ablation study allows a better understanding of the proposed method
Decision: Accept (Poster)