Supervised learning remains notoriously weak at out-of-distribution generalization. Unless training data and test data are drawn from the same distribution, predictive models tend to fail easily, and even seemingly minor natural variations in distribution turn out to defeat state-of-the-art models. Adversarial robustness, transfer learning and domain adaptation are but a few existing paradigms that anticipate differences of sorts between training and test distributions. In this work, we explore a new take on the problem of out-of-distribution generalization, without any mathematical structure or data available at training-time about the distributional differences.
We start from a simple observation. When presented with an unlabeled test instance , this instance itself gives us a hint about the distribution from which it was drawn. Our approach, called test-time training, allows the model parameters to depend on the test case , but not its unknown label . While such a sample-specific model is powerful in principle, seizing this information-theoretic advantage in practice raises new challenges that we begin to address in this work.
The route we take is to create a self-supervised learning problem based only on this single test case , which we use to update at test-time before we then make a prediciton on . Self-supervised learning uses an auxiliary task that automatically creates labels from unlabeled data. For the visual data we work with, the task rotates an image by a multiple of 90 degrees, and assigns the angle as the label (gidaris2018unsupervised).
Our approach can also be easily modified to work outside the standard supervised learning setting. If several test instances arrive in a batch, we can use the entire batch for test-time training. If test instances arrive online sequentially, we obtain further improvements by keeping the state of the parameters. After all, prediction is rarely a single event. The online setting can be the natural mode of deployment in practice, and shows the strongest improvements.
We experiment with test-time training for out-of-distribution generalization in the context of object recognition on several benchmarks. These include images with diverse types of corruption at various levels (hendrycks2019benchmarking), video frames of moving objects (shankar2019systematic), and a new test set of unknown distribution shifts collected by recht2018cifar. Our algorithm does not hurt on the original distribution, but makes substantial improvements under distribution shifts.
In all our experiments, we compare with a strong baseline (labeled joint training) that uses both supervised and self-supervised learning at training-time, but keeps the model fixed at test-time. Very recent work shows that additional training-time self-supervision improves out-of-distribution generalization hendrycks2019using. The joint training baseline we use corresponds to an improved implementation of their work. A comprehensive review of related work follows in section 5.
We complement the empirical results with theoretical investigations in Section 4
, of when test-time training is expected to help on a convex model, and establish an intuitive sufficient condition, which, roughly speaking, is to have correlated gradients between the loss functions of the main task and self-supervised task.
Next we describe the algorithmic details of our method. To setup notations, consider a standard
-layer neural network with parametersfor layer
. The stacked parameter vectorspecifies the entire model for a classification task with loss function on the test instance . We call this the main task, as indicated by the subscript of the loss function.
We assume to have training data drawn i.i.d. from a distribution . Standard empirical risk minimization corresponds to solving the optimization problem:
Our method requires a self-supervised auxiliary task with loss function . In this paper, we choose the rotation prediction task (gidaris2018unsupervised), which has been demonstrated to be simple and effective at feature learning for neural networks. The task simply rotates on the image plane by one of 0, 90, 180 and 270 degrees and have the model predict the angle of rotation as a four-way classification problem. Other self-supervised tasks in section 5 might also be used for our method.
The auxiliary task shares some of the model parameters up to a certain We think of those layers as a shared feature extractor. The auxiliary task uses its own task-specific parameters . We call the unshared parameters the self-supervised task branch, and the main task branch. Pictorially, the joint architecture is a -structure with a shared bottom and two branches. For our experiments, the self-supervised task branch has the exact same architecture as the main branch, except for the output dimensionality of the last layer due to the different number of classes in the two tasks.
Training is done in the fashion of multi-task learning (caruana1997multitask); the model is trained on both tasks on the same data drawn from . Losses for both tasks are added together, and gradients are taken for the collection of all parameters. The joint training problem is therefore
Now we describe the standard version of test-time training on a single test input . Simply put, test-time training finetunes the shared feature extractor by minimizing the auxiliary task loss on . This can be formulated as
Denote the (approximate) minimizer of Equation 3. The model then makes a prediction using the updated parameters . Empirically, the difference is negligible between minimizing Equation 3 over versus over both and . Theoretically, there exists a difference only when optimization is done with more than one step of gradient descent.
In the standard version of our method, the optimization problem in Equation 3 is always initialized with parameters obtained by minimizing Equation 2 on data from . After making a prediction on , is discarded. Outside of the standard supervised learning setting, when the test instances arrive online sequentially, the online version of test-time training solves the same optimization problem as in Equation 3 to update the shared feature extractor . However, on test input , is instead initialized with updated on the previous test input . This allows to take advantage of the distributional information available in as well as .
Test-time training naturally benefits from standard data augmentation techniques. On each test input , we perform the exact same set of random transformations as used for data augmentation during training to form a batch for test-time training.
3 Empirical Results
We experiment with both versions of our method (standard and online) on three kinds of out-of-distribution benchmarks, presented here in the order of visually low to high-level, which is roughly also the order of easy to hard. Our code is available at /https://github.com/yueatsprograms/ttt_cifar_release and https://github.com/yueatsprograms/ttt_imagenet_release.
Our architecture and hyper-parameters are consistent across all experiments. We use Residual Networks (ResNets) (he2016identity), which are constructed differently for CIFAR-10 111CIFAR-10 (krizhevsky2009learning) is a standard object recognition dataset with 10 classes of objects in natural scenes. The standard train / test split has 50,000 / 10,000 images, each of size 32-by-32 pixels.
(26-layer) and ImageNet222The ImageNet 2012 classification dataset (ILSVRC15) for object recognition has images from 1, 000 classes, 1.2 million for training and 50,000 for validation. Following standard practice (he2016deep; he2016identity; huang2016deep), the validation set is used as the test set.
(18-layer). ResNets on ImageNet have four groups, each containing convolutional layers with the same number of channels and size of feature maps; our splitting point is the end of the third group. ResNets on CIFAR-10 have three groups; our splitting point is the end of the second group. In addition, Batch Normalization (BN), a popular module in deep networks, is ineffective when training on small batches, for which the estimated batch statistics are less accurate(ioffe2015batch). This technicality hurts test-time training since each batch only contains (augmented) copies of a single image. Therefore our networks instead use Group Normalization (GN) (wu2018group), which achieves similar performance as BN on large batches without hurting on small ones. Results with BN are shown in Appendix E for completeness.
For Equation 2, optimization hyper-parameters are set to the default 333Namely, we use stochastic gradient descent (SGD) with weight decay and momentum; learning rate starts at 0.1 and is dropped by a factor of ten at two scheduled milestones, to 0.01 and 0.001. in standard practice (huang2016deep; he2016deep). For Equation 3he2018rethinking; liu2018rethinking) known to improve performance when finetuning, we do not use weight decay or momentum. For the standard version, we take ten gradient steps, using batches independently generated by the same image. For online we take only one step. The computational aspects of our method are discussed in Appendix C
. Following standard practice, the transformations used for data augmentation are random crop with padding and random horizontal flip for CIFAR-10(guo2017calibration; huang2016deep), and random resized crop and random horizontal flip for ImageNet (ioffe2015batch; he2016deep). Specifically, these transformations do not contain information about the distribution shifts.
In all the tables and figures, baseline refers to the plain ResNet model (using GN, unless otherwise specified); joint training refers to the model jointly trained on both the main task and the self-supervised task, fixed at test-time as in hendrycks2019using; test-time training refers to the standard version described section 2; and test-time training online refers to the online version that does not discard for arriving sequentially from the same distribution. Performance for test-time training online is calculated, just like the others, as the average over the entire test set; we always shuffle the test set before test-time training online to avoid ordering artifacts.
3.1 Common Corruptions
hendrycks2019benchmarking propose to benchmark robustness of neural networks on 15 types of corruptions from four broad categories: noise, blur, weather and digital. Each corruption type comes in five levels of severity, with level 5 the most severe (details and sample images in Appendix D). The corruptions are algorithmically simulated to mimic real-world corruptions as much as possible on copies of the test set for both CIFAR-10 and ImageNet. According to the authors, training should be done on the original training set, and the diversity of corruption types should make it difficult for any method to work well across the board if it relies too much on corruption specific knowledge.
Our results on the level 5 corruptions (most severe) are shown in Figure 9. Due to space constraints, our results on levels 1-4 are shown in Appendix E. Across all five levels and 15 corruption types, both versions of test-time training always improve over the baseline by a large margin. The standard version of test-time training always improves over joint training, and the online version often improves very significantly (10%) over joint training and never hurts by more than 0.2%. Specifically, test-time training online contributes 24% on the three noise types and 38% on pixelation. For the seemly unstable setup of a learning problem that abuses a single image, this kind of consistency is rather surprising.
The baseline ResNet-26 has error 8.9% on the original test set of CIFAR-10. The joint training baseline actually improves performance on the original to 8.1%. Most surprisingly, unlike many other methods that tradeoff original performance with robustness, test-time training further improves on the original test set by 0.2% consistently over many independent trials. This indicates that our method does not choose between specificity and generality.
Separate from our method, it is interesting to note that joint training consistently improves over the baseline, as discovered by hendrycks2019using. hendrycks2019benchmarking
have also experimented with various other training methods on this benchmark, and point to Adversarial Logit Pairing (ALP)(kannan2018adversarial) as the most effective. Results of this additional baseline on all levels of CIFAR-10-C are shown in Appendix E, along with its implementation details. While surprisingly robust under some of the most severe corruptions (especially the three noise types), ALP incurs a much larger error (by a factor of two) on the original distribution and some corruptions (e.g. all levels of contrast and fog), and hurts performance significantly when the corruptions are not as severe (especially on levels 1-3); this kind of tradeoff is to be expected for methods based on adversarial training, but not test-time training.
Our results on the level 5 corruptions (most severe) are shown in Figure 2. We use accuracy instead of error for this dataset because the baseline severely underperforms with most corruptions. The general trend is roughly the same as on CIFAR-10-C. Test-time training (standard version) always improves over the baseline and joint training, while the online version only hurts on the original by 0.1% over the baseline, but dramatically improves (by a factor of more than three) on many of the corruption types.
In the lower panel of Figure 2, we visualize how the accuracy (averaged over a sliding window) of the online version changes as more images are tested on. Due to space constraints, we show this plot on the original test set, as well as every third corruption type, following the same order as in the original paper. On the original test set, there is no visible change in performance after updating on the 50,000 samples. With corruptions, accuracy has already risen significantly after 10,000 samples, but is still rising towards the end of the 50,000 samples, indicating room for additional improvements if more samples were available. Without looking at a single label, test-time training online behaves as if we were training on the test set from the appearance of these plots.
3.2 Video Classification
The ImageNet Video Classification (VID) dataset was developed by shankar2019systematic from the Video Detection dataset of ILSVRC2015 (ILSVRC15)
, to demonstrate how deep learning models for object recognition trained on ImageNet (still images) fail to adapt well to video frames444 The VID dataset contains 1109 sets of video frames; each set forms a short video clip where all the frames are similar to an anchor frame. Our results are reported on the anchor frames. To map the 1000 ImageNet classes to the 30 VID classes, we use the max-conversion function in shankar2019systematic. . Without any modification for videos, we apply our method to VID on top of the same ImageNet model as in the previous subsection. Our results are shown in Table 2. Again, we use accuracy instead of error because the baseline performance is poor.
In addition, we take the seven classes in VID that overlap with CIFAR-10, and rescale those video frames to the size of CIFAR-10 images, as a new test set for the model trained on CIFAR-10 in the previous subsection. Again, we apply our method to this dataset without any modification. Our results are shown in Table 1, with a breakdown for each class. Noticing that test-time training does not improve on the airplane class, we inspect some airplane samples, and observe that most of them have black margins on the sides, which provide a trivial hint for the rotation prediction task. In addition, for airplanes captued in the sky, it is often impossible even for humans to tell if an image is rotated. This shows that our method requires the self-supervised task to be both well defined and non-trivial on the new domain.
3.3 CIFAR-10.1: A New Test Set With Unknown Distribution Shifts
CIFAR-10.1 (recht2018cifar) is a new test set of size 2000 modeled after CIFAR-10, with the exact same classes and image dimensionality, following the dataset creation process documented by the original CIFAR-10 paper as closely as possible. The purpose is to investigate the distribution shifts present between the two test sets, and the effect on object recognition. All models tested by the authors suffer a large performance drop on CIFAR-10.1 comparing to CIFAR-10, even though there is no human noticable difference, and both have the same human accuracy. This demonstrates how insidious and ubiquitous distribution shifts are, even when researchers strive to minimize them.
The distribution shifts from CIFAR-10 to CIFAR-10.1 pose an extremely difficult problem, and nobody has made a successful attempt to improve the performance of an existing model on this new test set, probably because 1) Researchers cannot even identify the distribution shifts, let alone describe them with mathematics. 2) The samples in CIFAR-10.1 are only revealed at test-time; and even if revealed during training, the distribution shifts are too subtle, and the sample size is too small, for domain adaptation algorithms(recht2018cifar).
On the original CIFAR-10 test set, our baseline has error 8.9%, and with joint training 8.1%; comparing to the first two rows of Table 3, both suffer the typical performance drop (by a factor of two). Test-time training yields an improvement of 0.8% (relative improvement of 4.8%) over joint training. We recognize that this improvement is still small comparing to the performance drop, but see it as an encouraging first step for this very difficult problem.
4 Towards Understanding Test-time Training
This section contains our preliminary study of when and why test-time training is expected to work. For convex models, we prove that positive gradient correlation between the loss functions leads to better performance on the main task after test-time training. Equipped with this insight, we then empirically demonstrate that gradient correlation governs the success of test-time training on the deep learning model discussed in Section 3.
Before stating our main theoretical result, we first illustrate the general intuition with a toy model. Consider a regression problem where denotes the input, denotes the label, and the objective is the square loss for a prediction . Consider a two layer linear network parametrized by and (where stands for the hidden dimension). The prediction according to this model is , and the main task loss is
In addition, consider a self-supervised regression task that also uses the square loss and automatically generates a label for . Let the self-supervised head be parameterized by . Then the self-supervised task loss is
Now we apply test-time training to update the shared feature extractor by one step of gradient descent on , which we can compute with known. This gives us
where is the updated matrix and is the learning rate. If we set where
then with some simple algebra, it is easy to see that the main task loss . Concretely, test-time training drives the main task loss down to zero with a single gradient step for a carefully chosen learning rate. In practice, this learning rate is unknown since it depends on the unknown . However, since our model is convex, as long as is positive, it suffices to set to be a small positive constant (see Lemma 1). If , one sufficient condition for to be positive (when neither loss is zero) is to have
For our toy model, both parts in Equation 8 have an intuition interpretation. The first part says that the mistakes should be correlated, in the sense that predictions from both tasks are mistaken in the same direction. The second part, , says that the decision boundaries on the feature space should be correlated. In fact, these two parts hold iff (see Lemma 2). To summarize, if the gradients have positive correlation, test-time training is guaranteed to reduce the main task loss. Our main theoretical result extends this to general smooth and convex loss functions.
Let denote the main task loss on test instance with parameters , and the self-supervised task loss that only depends on 555Because the main task branch and the self-supervised branch are kept fixed at test-time, we do not explicitly describe their parameters, and include them implicitly in the loss functions.. Assume that for all , is differentiable, convex and -smooth in , and both for all . With a fixed learning rate , for every such that
where i.e. test-time training with one step of gradient descent.
. The blue lines and bands are the best linear fits and the 99% confidence intervals. The linear correlation coefficients areand respectively, indicating strong positive correlation between the two quantities, as suggested by Theorem 1.
The proof is in Section B.2. Theorem 1 reveals gradient correlation as a determining factor of the success of test-time training in the smooth and convex case. In Figure 3, we empirically show that our insight also holds for non-convex loss functions, on the deep learning model and across the diverse set of corruptions considered in Section 3; stronger gradient correlation clearly indicates higher performance improvements over the baseline.
5 Related Work
Our work has been influenced by the successes and limitations of many related fields. Each of these fields contains maybe hundreds of interesting works, which we unfortunately do not have enough time and space to acknowledge in this draft. We apologize for the omissions and are happy to include additional citations upon request.
Learning on test instances.
Our idea is inspired by glasner2009super; shocher2018zero
, which learns to perform super-resolution only on a single image, by learning to recover the original image itself from its downsampled version. In addition,jain2011online
improves viola-jones for face detection, by using instances of faces with high confidence in an image to bootstrap the more difficult ones in the same image. The online version of our algorithm is inspired bymullapudi2018online, which makes video segmentation more efficient by using a student model that learns online from a teacher model. The idea of online updates has also been used in kalal2011tracking for tracking and detection. zhu2019neural, a concurrent work in echocardiography, improves the deep learning model that tracks myocardial motion and cardiac blood flow with sequential updates. Lastly, we share the philosophy of transductive learning (vapnik2013nature; gammerman1998learning), but have little in common with their classical algorithms e.g. nearest neighbors.
studies the robust risk: where is some loss function, and is the set of perturbations; one popular choice of is the ball, for . Works in this area rely heavily on the mathematical structure of , which might not be realistic models of perturbations in the real world. The most popular algorithms use either robust optimization (sinha2017certifying; raghunathan2018certified; wong2017provable; croce2018provable), or input transformations (guo2017countering; song2017pixeldefend), both can be seen as smoothing the decision boundary. This establishes a theoretical tradeoff between accuracy and robustness (zhang2019theoretically); intuitively, the more diverse is, the less effective this one-boundary-fits-all approach can be for a particular subset of . kang2019transfer show that empirically, robustness for one might not transfer to another, and training on the ball actually hurts robustness on the ball.
studies the effect of corruptions, perturbations, out-of-distribution examples, and real-world distribution shifts (hendrycks2019improving; hendrycks2019using; hendrycks2018using; hendrycks2016baseline). geirhos2018generalisation show that training on images corrupted by Gaussian noise makes deep learning models recover super-human performance on this particular noise type, but cannot improve performance on another those corrupted by another noise type e.g. salt-and-pepper noise.
Unsupervised domain adaptation
(a.k.a. transfer learning) studies the problem of distribution shift (from to ), when unlabled data from is available at training-time (tzeng2017adversarial; ganin2016domain; gong2012geodesic; long2016unsupervised; chen2018adversarial; chen2011co; hoffman2017cycada; csurka2017domain; long2015learning). We are inspired by this very active and successful community, especially (sun2019uda), and believe that progress in this community can motivate new algorithms in the framework of test-time learning. Our update rule can be viewed as performing one-sample unsupervised domain adaptation on the fly 666Note that typical unsupervised domain adaptation algorithms,such as those based on distributional discrepancy, adversarial learning, co-training and generative modeling, might not work in our framework because the concept of a target distribution, which has been so deeply rooted and heavily relied on, becomes ill-defined when there is only one sample from the target domain.. On the other hand, test-time learning comes from realizing the limitations of the unsupervised domain adaptation setting, that outside of the specific target distribution where data is available for training, generalization is still elusive. Previous works make the source and target distributions broader with multiple and evolving sources and targets without fundamentally address this problem (hoffman2018algorithms; hoffman2012discovering; hoffman2014continuous).
studies how to create labels from the data, by designing ingenious tasks that contain semantic information without human annotations, such as context prediction (doersch2015unsupervised), solving jigsaw puzzles (noroozi2016unsupervised)larsson2017colorproxy; zhang2016colorful), noise prediction (bojanowski2017unsupervised), and feature clustering (caron2018deep). Self-supervision has also been used on videos (Wang_UnsupICCV2015; CVPR2019_CycleTime). hendrycks2019using proposes that jointly training a main task and a self-supervised task (our joint training baseline in section 3) can improve robustness of the main task. The same idea is used in few-shot learning (su2019boosting), and domain generalization (carlucci2019domain).
studies when a meta distribution generates multiple environment distributions, some of which are available during training (source), while others are used for testing (target) (li2018deep; shankar2018generalizing; muandet2013domain; balaji2018metareg; ghifary2015domain; motiian2017unified; li2017deeper; gan2016learning). With only a few environments, information on the meta distribution is often too scarce to be helpful, and with many environments, we are back to the i.i.d. setting where each environment can be seen as a sample, and a strong baseline is to simply train on all the environments (li2019episodic). The setting of domain generalization is limited by the inherent tradeoff between specificity and generality of a fixed decision boundary, and the fact that generalization is again elusive outside of the meta distribution i.e. the actual .
Continual learning (a.k.a. learning without forgetting) studies when a model is made to learn a sequence of tasks, and not forget about the task at the beginning (li2017learning; lopez2017gradient; kirkpatrick2017overcoming; santoro2016meta). In comparison, test-time learning does not care at all about forgetting (and might even encourage it). Few (one)-shot learning studies extremely small training sets (maybe for some categories) (snell2017prototypical; vinyals2016matching; fei2006one; ravi2016optimization; li2017meta; finn2017model; gidaris2018dynamic). Our update rule can be viewed as performing one-shot self-supervised learning and can potentially be improved by progress in few-shot learning.
(a.k.a. online optimization) is a well-studied area of learning theory (shalev2012online; hazan2016introduction). The basic setting repeats the following: receive , predict , receive from a worst-case oracle and learn. Final performance is evaluated using the regret, colloquially how much worse than the best fixed model in hindsight. It is easy to see how our setting differs, even for the online version. We learn before predicting , but never receive any that is evaluated on, thus do not need to consider the worst-case orcale or the regret.
This paper took a long time to develop, and benefitted from conversations with many of our colleagues. We would especially like to thank Ben Recht and his students Ludwig Schmidt, Vaishaal Shanker and Becca Roelofs; Deva Ramanan and his student Achal Dave; and Armin Askari, Allan Jabri, Ashish Kumar, Angjoo Kanazawa and Jitendra Malik.
Appendix A A Theoretical Discussion on Our Variable Decision Boundary
In LABEL:intro, we claim that in traditional supervised learning gives a fixed decision boundary, while our gives a variable decision boundary. Here we explain this claim from a theoretical perspective.
Denote the input space and output space . A decision boundary is simply a mapping . Let be a model class e.g . Now consider a family of parametrized functions , where . In the context of deep learning, is the neural network architecture and contains the parameters. We say that is a fixed decision boundary w.r.t. and if there exists s.t. for every , and a variable decision boundary if for every , there exists s.t. . Note how selection of can depend on for a variable decision boundary, and cannot for a fixed one. It is then trivial to verify that our claim is true under those definitions.
A critical reader might say that with an arbitrarily large model class, can’t every decision boundary be fixed? Yes, but this is not the end of the story. Let , and consider the enormous model class which is capable of representing all possible mappings between and . Let simply be the mapping represented by . A variable decision boundary w.r.t. and then indeed must be a fixed decision boundary w.r.t. and , but we would like to note two things. First, without any prior knowledge, generalization in is impossible with any finite amount of training data; reasoning about and is most likely not productive from an algorithmic point of view, and the concept of a variable decision boundary is to avoid such reasoning. Second,selecting based on for a variable decision boundary can be thought of as “training” on all points ; however, “training” only happens when necessary, for the that it actually encounters.
Altogether, the concept of a variable decison boundary is different from what can be described by traditional learning theory. A more in depth discussion is beyond the scope of this paper.
Appendix B Proofs
Here we prove the theoretical results covered in Section 4.
b.1 Proofs for the toy problem
The following setting applies to the two lemmas; this is simply the setting of our toy problem, reproduced here for ease of reference. Consider a two layer linear network parametrized by (shared) and (fixed) for the two heads, respectively. Denote the input and the labels for the two tasks, respectively. For the main task loss
and the self-supervised task loss
test-time learning yields an updated matrix
where is the learning rate.
Following the exposition of section 4, denote
Assume for some . Then for any , we are guaranteed an improvement on the main loss i.e. .
From the exposition of section 4, we know that
which can also be derived from simple algebra. Then by convexity, we have
where the last inequality uses the assumption that , which holds because .
Define i.e. the Frobenious inner product, then
By simple algebra,
which has the same sign as .
b.2 Proof of Theorem 1
For any , by smoothness and convexity,
Then Equation 23 becomes
And by our assumptions on the gradient norm and gradient inner product,
Because we cannot observe in practice, we instead use a fixed learning rate , as stated in Theorem 1. Now we argue that this fixed learning rate still improves performance on the main task.
By our assumptions, , so . Denote , then by convexity of ,
Combining with Equation 26, we have
Since , we have shown that
Appendix C Computational Aspects of Our Method
At test-time, our method is batch_sizenumber_of_iterations times slower than regular testing, which only performs a single forward pass for each sample. As the first work on test-time learning, this paper is not as concerned about computational efficiency as improving robustness, but here we provide two potential solutions that might be useful, but have not been thoroughly verified. The first is to use the thresholding trick on , introduced as a solution for the small batches problem in section 2. For the models considered in our experiments, roughly of the test instances fall below the threshold, so test-time learning can only be performed on the other without much effect on performance, because those contain most of the samples with wrong predictions. The second is to reduce the number_of_iterations of test-time updates. For the online version, the number_of_iterations is already 1, so there is nothing to do. For the standard version, we have done some preliminary experiments setting number_of_iterations to 1 (instead of 10) and learning rate to 0.01 (instead of 0.001), and observing results almost as good as the standard hyper-parameter setting. A more in depth discussion on efficiency is left for future works, which might, during training, explicitly make the model amenable to fast updates.
Appendix D Sample Images from the Common Corruptions Benchmark
Appendix E Additional Results on the Common Corruptions Dataset
For table aethetics, we use the following abbreviations: B for baseline, JT for joint training, TTT for test-time training standard version, and TTTO for test-time training online version.
We have also abbreviated the names of the corruptions. The full names are, in order: original test set, Gaussian noise, shot noise, impulse noise, defocus blur, glass blue, motion blur, zoom blur, snow, frost, fog, brightness, contrast, elastic transformation, pixelation, and JPEG compression.
e.1 Results using Batch Normalization
As discussed in section 3, Batch Normalization (BN) is ineffective for small batches, which are the inputs for test-time training (both standard and online version) since there is only one sample available when forming each batch; therefore, our main results are based on a ResNet using Group Normalization (GN). Here we provide results of our method on CIFAR-10-C level 5, with a ResNet using Batch Normalization (BN). These results are meant to be merely a point of reference for the curious readers, instead of our technical contributions.
In the early stage of this project, we have experimented with two potential solutions to the small batches problem with BN. The naive solution is to fix the BN layers during test-time training. but this diminishes the performance gains since there are fewer shared parameters. The better solution, adopted for the results below, is hard example mining: instead of updating on all inputs, we only update on inputs that incur large self-supervised task loss , where the large improvements might counter the negative effects of inaccurate statistics.
Test-time training (standard version) is still very effective with BN. In fact, some of the improvements are quite dramatic, such as on contrast (34%), defocus blue (18%) and Gaussian noise (22% comparing to joint-training, and 16% comparing to the baseline). Performance on the original distribution is still almost the same, and the original error with BN is in fact slightly lower than with GN, and takes half as many epochs to converge.
We did not further experiment with BN because of two reasons: 1) The online version does not work with BN, because the problem with inaccurate batch statistics is exacerbated when training online for many (e.g. 10000) steps. 2) The baseline error for almost every corruption type is significantly higher with BN than with GN. Although unrelated to the main idea of our paper, we make the interesting note that GN significantly improves model robustness.
e.2 Additional Baseline: Adversarial Logit Pairing
As discussed in subsection 3.1, hendrycks2019benchmarking point to Adversarial Logit Pairing (ALP) (kannan2018adversarial) as an effective method for improving model robustness to corruptions and perturbations, even though it was designed to defend against adversarial attacks. We take ALP as an additional baseline on all benchmarks based on CIFAR-10 (using GN), following the training procedure in kannan2018adversarial and their recommended hyper-parameters. The implementation of the adversarial attack comes from the codebase of ding2019advertorch. We did not run ALP on ImageNet because the two papers we reference for this method, kannan2018adversarial and hendrycks2019benchmarking, did not run on ImageNet or make any claim or recommendation.
e.3 Results on CIFAR-10-C and ImageNet-C, level 5
The following two tables correspond to the bar plots in section 3.
e.4 Results on CIFAR-10-C, levels 1-4
The following bar plots and tables are on levels 1-4 of CIFAR-10-C. The original distribution is the same for all levels, so are our results on the original distribution.