DO DEEP NETWORKS TRANSFER INVARIANCES
Year: 2021

Abstract:
To generalize well, classifiers must learn to be invariant to nuisance transformations that do not alter an input’s class. Many problems have “class-agnostic” nuisance transformations that apply similarly to all classes, such as lighting and background changes for image classification. Neural networks can learn these invariances given sufficient data, but many real-world datasets are heavily class imbalanced and contain only a few examples for most of the classes. We therefore pose the question: how well do neural networks transfer class-agnostic invariances learned from the large classes to the small ones? Through careful experimentation, we observe that invariance to class-agnostic transformations is still heavily dependent on class size, with the networks being much less invariant on smaller classes. This result holds even when using data balancing techniques, and suggests poor invariance transfer across classes. Our results provide one explanation for why classifiers generalize poorly on unbalanced and long-tailed distributions. Based on this analysis, we show how a generative model approach for learning the nuisance transformations can help transfer invariances across classes and improve performance on a set of imbalanced image classification benchmarks.

heading: 1 INTRODUCTION
text: Good generalization in machine learning models requires ignoring irrelevant details: a classifier should respond to whether the subject of an image is a cat or a dog but not to the background or lighting conditions. Put another way, generalization involves invariance to nuisance transformations that should not affect the predicted output. Deep neural networks can and do learn invariances given sufficiently many diverse examples. For example, we can expect our trained “cat vs dog” classifier to be invariant to changes in the background provided the training dataset contains images of cats and dogs with varied scenery. However, if all the training examples for the “dog” class are set in grassy fields, our classifier might be confused by an image of a dog in a house (Beery et al., 2018).
This situation is problematic for imbalanced datasets, in which the amount of training data varies from class to class. Class imbalance is common in practice, as many real-world datasets follow a long-tailed distribution where a few head classes have many examples, and each of the remaining tail classes have few examples. Hence even if the cumulative number of examples in a long-tailed dataset is large, classifiers may struggle to learn invariances for the smaller tail classes. And while augmentation can address this issue by increasing the amount and variety of data in the tail classes, this strategy is not feasible for every nuisance transformation (e.g., modifying an image’s background scenery). On the other hand, many nuisance transformations such as lighting changes are “class agnostic:” they apply similarly to examples from any class, and should generalize well across classes (Hariharan & Girshick, 2016). Ideally a trained model should automatically transfer invariance to class agnostic transformations from larger classes to smaller ones. This observation raises the question: how well do deep neural network classifiers transfer learned invariances across classes?
In this work, we find empirical evidence that neural networks transfer learned invariances poorly across classes, even after applying balancing strategies like oversampling. For example, on a longtailed dataset where every example is rotated uniformly at random, classifiers tend to be rotationally invariant for images from the head classes but not on images from the tail classes. To this end, we present a straightforward method for more effectively transferring invariances across classes. We first train an input conditioned but class-agnostic generative model which captures a dataset’s nuisance transformations, where withholding explicit class information encourages transfer between
classes. We then we use this generative model to transform training inputs, akin to learned data augmentation training the classifier. We ultimately show that the resulting classifier is more invariant to the nuisance transformations due to better invariance on the tail classes, which in turn leads to better test accuracy on those classes.
Contributions. The primary contribution of this paper is an empirical study concerning whether deep neural networks learn invariances in long-tailed and class-imbalanced settings. We analyze the extent to which neural networks (fail to) transfer learned invariances across classes, and we argue that this lack of invariance explains poor performance on real-world class-imbalanced datasets. Our analysis suggests that one path to improving imbalanced classification is to develop approaches that better transfer invariances across classes. We experiment with one such approach, which we call Generative Invariance Transfer (GIT), in which we train a generative model of a task’s nuisance transformations and then use this model to perform data augmentation for the classifier. We find that combining GIT with existing methods such as resampling improves balanced accuracy on imbalanced image classification benchmarks such as GTSRB and CIFAR-LT.

heading: 2 RELATED WORK
text: Real-world datasets are often class imbalanced, and state-of-the-art classifiers often perform poorly under such conditions. One particular setting of interest is when the class distribution is longtailed, where most of the classes have only a few examples (Liu et al., 2019; Guo et al., 2016; Thomee et al., 2016; Horn & Perona, 2017). Researchers have proposed many approaches for this setting, including correcting the imbalance when sampling data (Buda et al., 2018; Huang et al., 2016; Chawla et al., 2002; He & Garcia, 2009), using modified loss functions (Cao et al., 2019; Lin et al., 2017; Cui et al., 2019), and modifying the optimizer (Tang et al., 2020). These methods generally do not study the question of invariance transfer and are complementary to Generative Invariance Transfer. Yang & Xu (2020) study the mixed value of imbalanced labels and propose learning class-agnostic information using self-supervised training, while GIT learns class-agnostic transformations to use as data augmentation. Wang et al. (2017) propose implicit transfer learning from head to tail classes using a meta-network that generates the weights of the classifier’s model. Here we quantitatively measure per-class invariances to more precisely explain why transfer learning may help on imbalanced problems, and explicitly transfer across classes with a generative model.
Toward understanding the failure modes of classifiers trained on real-world datasets, a rapidly growing body of work has sought to study the robustness of commonly-used machine learning models. Notably, researchers have shown that the performance state-of-the-art models is susceptible to a wide range of adversarial attacks (Biggio & Roli, 2018; Madry et al., 2017) and distributional shifts (Taori et al., 2020; Hendrycks et al., 2020; Koh et al., 2021). Ultimately, the fragility of these models is a significant barrier to deployment in safety-critical applications such as medical imaging (Bashyam et al., 2020) and autonomous driving (Chernikova et al., 2019). In response to these fragilities, recent methods have learned the distributional shifts present in the data using generative models
and then use these learned transformations for robust training (Robey et al., 2020; Wong & Kolter, 2020). These works assume pairs or groupings of transformed and untransformed examples, so that a generative model can learn the distribution shift. In our imbalanced setting, generative invariance transfer aims to learn transformations from the head classes that apply to the tail classes of the same dataset, and does not assume the data is paired or grouped.
There is a general interest in obtaining invariances for machine learning models (Benton et al., 2020; Zhou et al., 2021). Data augmentation (Beymer & Poggio, 1995; Niyogi et al., 1998) can be used to train classifiers to be invariant to certain hand-picked transformations, but requires the practitioner to know and implement those transformations in advance. In search of greater generality, Antoniou et al. (2017) use a trained GAN as data augmentations for training a downstream classifier. Similarly, Mariani et al. (2018) use a GAN to generate more examples for the minority classes in imbalanced classification. Learned augmentation can also be done in feature space, to avoid learning a generative model of the high dimensional input space (Yin et al., 2018; Chu et al., 2020). In the low-shot setting Hariharan & Girshick (2016) study the notion of transferring generalizable (or classagnostic) variation to new classes, and Wang et al. (2018) learn to produce examples for new classes using meta-learning. Work in neural style transfer (Gatys et al., 2015b;a; Johnson et al., 2016) has long studied how to leverage trained neural networks to transfer variation between images or domains. In particular, GIT leverages advances in image-to-image translation (Isola et al., 2016; Zhu et al., 2017; Huang et al., 2018) as a convenient way to learn nuisance transformations and transfer them between classes. Our work carefully quantifies invariance learning under class imbalance, which can explain why leveraging generative models of transformations can improve performance. There is prior work analyzing how learned representations and invariances are affected by noise and regularization (Achille & Soatto, 2018), task diversity (Yang et al., 2019), and data diversity (Madan et al., 2021). The latter is most relevant to our own analysis, which studies how invariance is affected by the amount of data per class.

heading: 3 INVARIANCE TRANSFER IN CLASS-IMBALANCED DATASETS
text: In this section we empirically analyze the invariance of trained classifiers to nuisance transformations, and the extent to which these classifiers transfer invariances across classes. In particular, we first introduce concepts related to invariance in the imbalanced setting, then define a metric for measuring invariance before describing our experimental setup. Finally, we present and analyze the observed relationship between invariance and class size.

heading: 3.1 SETUP: CLASSIFICATION, IMBALANCE, AND INVARIANCES
text: In the classification setting, we have input-label pairs (x, y), with y taking values in {1, · · · , C} where C is the number of classes. We will consider a neural network model parameterized by weightsw that is trained to estimate the conditional probabilities P̂w(y = j|x). The classifier selects the class j with the highest estimated probability. Given a training dataset {(x(i), y(i))}Ni=1 ∼ Ptrain, empirical risk minimization (ERM) minimizes average loss over training examples. But in the classimbalanced setting, the distribution of {y(i)} in our training dataset is not uniform, and ERM tends to perform poorly on the minority classes. In real world scenarios we typically want to perform well on all classes, e.g. in order to classify rare diseases properly (Bajwa et al., 2020) or to ensure fairness in decision making (Hinnefeld et al., 2018). Hence we evaluate classifiers using class-balanced metrics, which is equivalent to evaluating on a test distribution Ptest that is uniform over y.
To analyze invariance, we assume there is a θ ∼ Q parameterizing a family of nuisance transformations T (·; θ) that do not affect labels, i.e. (x, y) and (T (x; θ), y) are the same in distribution. As a simple example, consider an image dataset where images in each class can be rotated in any way with equal likelihood. Then T (·; θ) corresponds to 2D rotation by angle θ ∼ Unif(0, 2π). Given that the nuisance transformations are assumed to not impact the labels, we expect a good classifier to be invariant to such transformations, i.e.,
P̂w(·|x) = P̂w(·|T (x; θ)), ∀x, θ. (1)
That is, the estimated conditional class probabilities should be unchanged by these transformations.

heading: 3.2 MEASURING LEARNED INVARIANCES
text: To quantify the extent to which classifiers learn invariances, we measure the expected KL divergence (eKLD) between its estimated distributions for untransformed and transformed inputs:
eKLD(P̂w) = Ex,θ [ DKL ( P̂w(·|x)||P̂w(·|T (x; θ) )] (2)
This is a non-negative number, with lower eKLD corresponding to more invariance; a classifier totally invariant to T would have an eKLD of 0. We can compute this metric in practice if we have the nuisance transformation T on hand: By sampling transformation parameters {θ(j)} and applying them to held out inputs, we can estimate the expectation in Eq. 2. To study how invariance depends on class size, we can also naturally compute the class-conditional eKLD by restricting the expectation over x to examples from a given class j.
Calculating eKLD and studying invariance requires access to a dataset’s underlying nuisance transformation family T , but for most real world datasets we do not know T a-priori. Instead, we create synthetic datasets that contain a known nuisance transformation family. Like RotMNIST (Larochelle et al., 2007), a common benchmark for rotation invariance, we create these datasets by transforming each example in a natural dataset. This is different from data augmentation, where multiple randomly sampled transformations would be applied to the same image throughout training. We want to test how classifiers learn invariances from a limited amount of data diversity; providing the transformation as data augmentation artificially boosts the observed data diversity and we use it as an Oracle comparison in later experiments.
Since MNIST only contains 10 classes, we use Kuzushiji-49 (Clanuwat et al., 2018) which has 49 classes allowing for a finer-grained study across different class sizes. We create synthetic datasets using three different transformation families: image rotation (K49-ROT-LT), varying background intensity (K49-BG-LT), and image dilation or erosion (K49-DIL-LT). Appendix Figure 7 shows representative image samples from each of these datasets. To make the training datasets long-tailed (LT), we choose an arbitrary ordering of classes from largest to smallest. Then we selectively remove examples from classes until the frequency of classes in the training dataset follows Zipf’s law with parameter 2.0, while enforcing a minimum class size of 5. We repeat this process with 30 randomly sampled orderings of the classes from largest to smallest, to construct 30 different long-tailed training datasets for each variant. Each long-tailed training set has 7864 training examples, with the largest class having 4828 and the smallest having 5. Since we are interested in either per-class or class-balanced test metrics, we do not modify the test set class distribution.
Good classifiers for K49-ROT-LT, K49-BG-LT, and K49-DIL-LT should clearly be rotation, background, and dilation/erosion invariant, respectively, for inputs from any class. We can train classifiers and measure their invariance for inputs of each class by estimating per-class eKLD. That is, we first sample more transformations and then measure how predictions change on held-out test inputs. For training we use both standard ERM and CE+DRS (Cao et al., 2019), which stands for delayed (class-balanced) resampling with standard cross-entropy loss. DRS samples training examples naively just as in ERM for the initial epochs of training, then switches to class-balanced sampling for the later epochs of training. We train a separate classifier using each method on each training dataset, then calculate each classifier’s per-class eKLD on held out test examples.
Figure 1 shows how the resulting per-class eKLD varies with class size. The eKLD curves for both methods show a clear pattern on all three transformation families: invariance decreases as classes get smaller. This result, while intuitive, shows quantitatively that deep neural networks learn invariances non-uniformly on imbalanced datasets. It suggests that they fail to transfer learned invariances across classes despite the nuisance transformation families being fairly class-agnostic. Although these results use a ResNet architecture, Appendix C.2 shows similar results for non-ResNet CNNs. Note that by construction, smaller classes contain both fewer original K49 examples and less transformation diversity. Yet Appendix 8 shows the same trend for datasets where the number of original K49 examples is the same across all classes, with larger classes only containing more sampled transformations of the same images. This shows that the trend is largely due to observed transformation diversity, rather than the number of original K49 examples.
Figure 1 also shows that training classifiers with resampling (CE+DRS) results in generally lower eKLD (more invariance) for the same class size. This effect may partly explain why resampling can improve class balanced metrics such as balanced test accuracy. However, the eKLD curves show
that there is clearly still room for improvement and even DRS does not achieve close to uniform invariance learning across classes. One explanation for this is that DRS can show the classifier the same minority class images more often, but cannot increase the transformation diversity of those images (e.g., DRS cannot by itself create more examples of rotated images from the minority classes). This suggests that learning the transformation family T (·; θ), combined with resampling schemes, can help classifiers achieve uniform invariance across classes.

heading: 4 TRANSFERRING INVARIANCES WITH GENERATIVE MODELS
text: We’ve seen that classifiers do a poor job learning invariance to nuisance transformations on the tail classes of long-tailed datasets. Here we explain how Generative Invariance Transfer (GIT) transfers invariance across classes by explicitly learning the underlying nuisance family T (·; θ).

heading: 4.1 LEARNING NUISANCE TRANSFORMATIONS FROM DATA
text: If we have the relevant nuisance transformations T (·; θ), we can use them as data augmentation to enforce invariance across all classes. Since this is rarely the case in practice, GIT approximates T by training an input-conditioned generative model T̃ (·; θ̃) to learn the nuisance transformations. Here θ̃ ∼ Q̃ parameterizes the generative model’s transformation just as θ ∼ Q parameterizes the true transformation family. An input-conditioned generative model of the transformation is advantageous for class-agnostic nuisances. Since the class-specific features are already present in the input, the model can focus on learning the class-agnostic transformation, which by assumption should transfer well between classes.
To train the generative model in the image classification setting, we borrow architectures and training procedures from the literature concerning multimodal image-to-image translation networks (MIITNs). MIITNs can transform a given input image x according to different nuisances learned from the data, generating varied output samples. The multimodality is ideal for capturing the full diversity of nuisance transformations present in the training data. Our experiments build off of a particular MIITN framework called MUNIT (Huang et al., 2018), modified to learn transformations between examples in a single dataset rather than between two different domains (see Appendix A for details). Although we are not aware of any work training MUNIT-like models to learn rotation, we successfully train MUNIT models to learn background intensity variation (K49-BG-LT) and dilation/erosion (K49-DIL-LT). Figure 2 shows the diversity of transformations these models produce from a given input. We see qualitatively that these models properly transform even inputs from the smallest class, evidencing successful transfer between classes. While these and later results show MUNIT successfully learns certain natural and synthetic transformations in imbalanced datasets, we note that GIT makes MUNIT-exclusive assumptions, and other approaches for learning transformations can be considered depending on the setting.
Once we have the trained generative model, GIT uses the generative model as a proxy for the true nuisance transformations to perform data augmentation for the classifier, with the goal of improving invariance to these nuisance transformations for the small classes. Given a training minibatch {(x(i), y(i))}|B|i=1, we sample transformation parameters {θ̃(i)} |B| i=1 and transform each input x(i) ← T̃ (x(i); θ̃(i)) while keeping the label fixed. This augments the batch and boosts the diversity of examples that the classifier sees during training, particularly for the smaller classes. The preaugmentation batches can be produced by an arbitrary sampling routine BATCHSAMPLER, such as a class-balanced sampler. We can also augment more selectively to mitigate the possibility of defects in the generative model hurting performance, especially on the large classes where we already observe good invariance and where the augmentation may be unnecessary. First, we introduce a cutoff
K such that GIT only augments examples from classes with fewer than K examples. Second, we use GIT to augment only a proportion p ∈ [0, 1] of each batch, so that the classifier sees a mix of augmented and “clean” data. Typically p = 0.5 in our experiments. Algorithm 1 details the GIT augmentation procedure explicitly.
Algorithm 1 Generative Invariance Transfer: Classifier Training Input: D, the imbalanced training dataset Input: BATCHSAMPLER, a minibatch sampling subroutine Input: T̃ (·; θ̃), a generative model of transformations trained on D Input: UPDATEMODEL, a procedure that updates a classifier model given a minibatch
while not done do B ← {(x(i), y(i))}|B|i=1 = BATCHSAMPLER(D) . Sample raw batch for i = 1, · · · ,Round(p× |B|) do . Augment proportion p of batch
if CLASSSIZE(y(i)) ≤ K then . Optionally only augment the smaller classes. Sample θ̃(i) ∼ Q̃ x(i) ← T̃ (x(i); θ̃(i))
end if end for UPDATEMODEL(B) . Update model on batch
end while

heading: 4.2 GIT IMPROVES INVARIANCE ON SMALLER CLASSES
text: 101 102 103 0.00
0.02
0.04
0.06
0.08
0.10
0.12
K49-BG-LT (Background Intensity)
101 102 103 0.0
0.2
0.4
0.6
0.8 K49-DIL-LT (Dilation/Erosion)
Method ERM CE+DRS CE+DRS+GIT Oracle
eKLD after Generative Invariance Transfer (GIT)
Class size
eK LD
Figure 3: We observe that the expected KL divergence (eKLD) is lower for smaller classes when using generative invariance transfer (GIT). That is, GIT makes classifiers more uniformly invariant to the nuisance transform regardless of class size.
As we saw in Figure 2, MIITNs can be trained to learn the relevant nuisance transformations for K49-BG-LT and K49-DIL-LT. Thus, given a trained MIITN, we aim to evaluate whether GIT can actually improve invariance on the smaller classes by transfering invariances from large to small classes. To do so, we measure the per-class eKLD metric on GIT-trained classifiers, with lower eKLD suggesting greater invariance. In particular, we train the classifiers using Algorithm 1 where BATCHSAMPLER is the delayed resampler and where UPDATECLASSIFIER uses gradient updates with respect to the cross-entropy (CE) loss function; we refer to this combined method as CE+DRS+GIT.
For the K49 experiments only we disable the class size cutoff K, since we want to observe GIT’s effect at all class sizes. As an “Oracle” comparison we also replace GIT augmentation by the true nuisance transformation we used to construct the dataset, providing an unlimited amount of true transformation diversity (the training scheme is otherwise identical to CE+DRS).
Figure 3 shows the average per-class eKLD of classifiers trained by CE+DRS+GIT, compared with ERM, CE+DRS, and the Oracle. We clearly observe that GIT achieves more uniform invariance across class sizes than CE+DRS or ERM, with the biggest improvements for the smallest classes. We also observe that GIT can hurt invariance on the largest classes, where there is already sufficient ground truth data such that imperfections in the generative model end up degrading performance. This will justify using the class-size cutoff K for GIT augmentations in our later experiments.

heading: 5 EXPERIMENTS
text: We have seen in Section 3 that classifiers transfer invariances poorly and can struggle to learn invariances on the smallest classes, and in Sec 4 that Generative Invariance Transfer (GIT) can lead to more uniform invariances across all class sizes. In this section, we verify that more invariant classifiers do indeed perform better, as measured by metrics such as balanced test accuracy. We also aim to understand whether GIT can be combined with other techniques for addressing class imbalance, and determine whether it is empirically important to only augment smaller classes.

heading: 5.1 EXPERIMENTAL SETUP
text: Comparisons. In our main comparisons, we will evaluate the performance of Generative Invariance Transfer (GIT) and study how it interacts with other techniques for addressing class imbalance, which include resampling schemes and modified loss functions. We use ERM to denote the standard training procedure with cross entropy loss, where examples for training minibatches are sampled uniformly from the dataset. As in Section 3 we can alternatively train with delayed resampling, which we will refer to as CE+DRS. In addition to the typical cross entropy loss, we will compare to two recent loss functions that are representative of state-of-the-art techniques for learning from long-tailed data: the LDAM (Cao et al., 2019) and Focal (Lin et al., 2017) losses, which are designed to mitigate the imbalanced learning problem. Throughout the experiments, we will combine these loss functions with different sampling strategies (e.g. CE+DRS) and (optionally) GIT, e.g. “LDAM+DRS+GIT.” After training we evaluate performance by balanced test set accuracy.
Datasets. We evaluate combinations of these methods on several long-tailed image classification benchmarks. Following the standard in long-tailed literature, we construct long-tailed training datasets by removing examples from certain classes until the class frequencies follow a long-tailed distribution. Appendix Figure 7 shows random samples from each the head and tail classes of each dataset. Aside from the long-tailed Kuzushiji-49 (K49-LT) variants of Section 3, we use:
GTSRB-LT is a long-tailed variant of GTSRB (Stallkamp et al., 2012; 2011) which contains images from 43 classes of German traffic signs in a large variety of lighting conditions and backgrounds, a natural source of nuisance transformations. We resize every image to have dimensions 32x32, randomly sample 25% of our training set as the validation set and use the rest to construct the longtailed training dataset. We make the training dataset long-tailed by selectively removing examples so that the class frequencies follow a Zipf’s law with parameter 1.8. We fix the minimum number of training samples for a particular class to be 5 — resulting in a training dataset where the most frequent class has 1907 examples, and the least frequent class has 5 examples. Since we are calculating class-balanced test metrics, we leave the test set unchanged.
CIFAR-10-LT and CIFAR-100-LT are long-tailed CIFAR (Krizhevsky, 2009) variants used in previous long-tailed classification literature (Cao et al., 2019; Tang et al., 2020). It has with 32 × 32 images in 10 or 100 class, respectively. Our setup is identical to Cao et al. (2019), with class frequency in the training set following an exponential distribution with the imbalance ratio (ratio of number of training examples between most frequent and least frequent class) set to 100. Similar to GTSRB-LT, we keep the test sets unchanged as we are calculating class-balanced test metrics.
TinyImageNet-LT is constructed from TinyImageNet (Le & Yang, 2015) similarly to CIFAR-LT. TinyImageNet has 200 classes, with 500 training and 50 test example per class. We remove training examples to achieve an imbalance ratio of 100 and keep the test sets unchanged.
Training. For GTSRB-LT and CIFAR-LT we train ResNet32 (He et al., 2015) models for 200 epochs with batch size 128, optimized by SGD with momentum 0.9, weight decay 2 × 10−4, and initial learning rate 0.1. The learning rate decays by a factor of 10 at epochs 160 and 180. For K49-LT we instead use a ResNet20 backbone trained for 50 epochs, with learning rate decays at 30 and 40 epochs. For TinyImageNet-LT we use an EfficientNet-b4 (Tan & Le, 2019) backbone and a cosine annealing learning rate scheduler (Loshchilov & Hutter, 2017). See appendices B and C.1 for further classifier and baseline training details. We implement the GIT MIITNs using MUNIT (Huang et al., 2018) trained for 140, 000 steps (GTSRB-LT and CIFAR-LT), 200, 000 steps (TinyImageNet-LT) or 10, 000 steps (K49-LT). We use the Adam (Kingma & Ba, 2014) optimizer with learning rate 0.0001 and batch size 1.

heading: 5.2 RESULTS
text: K49-LT. In Section 4.2 we trained MIITNs on K49-BG-LT and K49-DIL-LT and saw that using GIT to augment training led to more uniform invariance against each dataset’s nuisance transform, with the largest improvements on the smallest class sizes. Table 1 shows that GIT also improves balanced accuracy over DRS, for both the CE and LDAM losses. ORACLE replaces GIT augmentation by the true transformation we used to construct the dataset. For K49-BG-LT, we find that GIT actually outperforms the ORACLE. This suggests that GIT is learning natural nuisances from the original K49 dataset, in addition to the synthetic background intensity transformation.
GTSRB-LT. For GIT classifier training we set the class size cutoff parameter K = 25. Table 1 demonstrates that GIT can be combined with CE+DRS, Focal+DRS and LDAM+DRS and in each case give a significant boost over these methods. Appendix Table 3 shows further comparisons. Figure 4 shows how the trained MIITN varies the original image’s lighting conditions.
CIFAR-LT and TinyImageNet-LT. When training classifiers with GIT, we set the class size cutoff parameter K = 500 for CIFAR-10 and K = 100 for CIFAR-100 and TinyImageNet-LT. Table 1 shows the benefit of combining GIT with CE+DRS, Focal+DRS and LDAM+DRS, resulting in improvement for all three methods on both CIFAR-LT and TinyImageNet-LT benchmarks. Figure 4 shows samples from the MIITN trained on CIFAR-100-LT: we see that it has learned to vary the input image’s object color and background, even for inputs from the smallest classes. Appendix Table 4 contains results for further combinations of GIT with other imbalanced training methods, where we see that GIT gives the largest improvements when combined with resampling based methods. Intuitively, GIT primarily helps enforce invariance by augmenting the examples from smaller classes, but without resampling most of the observed data will be from the larger classes. Hence it makes the most sense to pair GIT with some resamping based method for best performance.
6 ABLATION STUDIES
GIT class size cutoff: The samples generated by the trained MIITNs (Figures 2 and 4) capture a diverse set of nuisances, but have poorer image quality than the original images. When introducing GIT in Algorithm 1, we hypothesized that poor generated sample quality could hurt performance for classes that already have a lot of examples, so we introduced a class size cutoff K to only augment classes with fewer than K examples. By disabling this cutoff and applying GIT to all classes, we can inspect how GIT affects test accuracy for each individual class to validate this hypothesis.
Figure 5 reports per-class performance for each of the ten classes in CIFAR-10-LT, arranged by class size. We see that using GIT without the cutoff boosts accuracy for the smaller classes, but can lower accuracy for the larger classes. In contrast, using the cutoff (K = 500) reduces the accuracy drop on the largest classes, while maintaining strong improvements on small classes. Table 2 directly
compares GIT’s performance with and without the class size cutoff. We see that using a class-size cutoff improves performance across the board. The differences are most pronounced for GTSRB followed by CIFAR-100 and CIFAR-10. We expect that this might be the case because CIFAR-10 has more coarse class definitions, such that the MIITN is less likely to corrupt the label.
Automated data augmentation: Since we can interpret GIT as a form of learned data augmentation, we also compare it to RandAugment (Cubuk et al., 2019), an automated data augmentation scheme carefully designed to have a small search space over augmentation parameters. As RandAugment has published tuned hyperparameters for CIFAR10/100, we use those and compare in CIFAR-LT. GIT outperforms RandAugment when using the LDAM loss, but RandAugment performs comparably to or better than GIT with CE or FOCAL loss. This indicates that RandAugment’s set of transformations and search space work well in the CIFAR setting.

heading: 7 CONCLUSION
text: We study how deep neural network classifiers learn invariances to nuisance transformations in the class imbalanced setting. Even for simple simple class agnostic transforms such as rotation, we find that learned invariance depends heavily on class size, with the trained classifier being much less invariant for inputs from the smaller classes. This suggests that classifiers do not inherently do a good job of transferring invariances learned from the larger classes to the smaller classes, and is one way of explaining why they tend to perform poorly on heavily imbalanced or long-tailed classification problems. Motivated by the transfer problem, we explore Generative Invariance Transfer (GIT) as a method for directly learning a generative model of a dataset’s nuisance transformations. We use this generative model during classifier training as a form of data augmentation to enforce invariance and observe both more uniform invariance learning across class sizes and improved balanced test accuracy on long-tailed benchmarks. Despite the observed improvements, GIT relies on being able to train a generative model to learn the dataset’s nuisance transformations. Imperfections in the generative model can harm downstream performance, and we speculate that future improvements in generative modeling would lead to even greater performance gains. Since this work is about transferring invariances between classes, the focus is largely on class-agnostic transformations. Class-specific transformations would not be amenable to transfer, and handling them will likely require a different approach.
Our analysis also raises the question: why do deep classifiers struggle to transfer class-agnostic invariances across classes? We believe that an explanation for this effect is an interesting problem to be resolved by progress in the theory of deep learning. Additionally, although our analysis focused on the interaction between class size and invariance, these techniques used here could be extended to measure invariance in other contexts. Additionally, a dataset can be class-balanced but imbalanced along other semantic dimensions not captured by the label, such groupings often studied in distributionally robust optimization (Sagawa et al., 2019). Further research on transferring invariances despite imbalance along more general dimensions could lead to more broadly generalizable and robust deep learning methods.

heading: 8 REPRODUCIBILITY STATEMENT
text: For our baseline experiments, we use publicly available implementations and their existing hyperparameter values, linked or cited in Appendix B. For Generative Invariance Transfer we use a publicly available MUNIT implementation, with our modifications described in Appendix A. Classifier training with GIT is described in Algorithm 1. Since GIT effectively acts as a learned data augmentation and doesn’t require modifying the classifier itself, for ease of comparison and reproducibility we kept details such as classifier architecture and optimization hyperparameters unchanged relative to the baselines. Appendix C.2 describes how to construct the K49-LT datasets, while Section 5.1 describe the GTSRB-LT and CIFAR-LT datasets. All code and pre-trained MIITN and classifier weights will be released upon publication.

heading: A MUNIT TRAINING DETAILS
text: We implement our generative models using the MUNIT architecture and training algorithm (Huang et al., 2018), using the official source code at https://github.com/NVlabs/MUNIT. Although the architectures, optimizers, and most other training details are unchanged, MUNIT is designed to train on two datasetsA andB and learns two generative modelsGA→B andGB→A to map between them. As we are only interested in learning transformations between images in the same (imbalanced) dataset, we set both A and B to be our one dataset and, after training, arbitrarily take GA→B as the learned generative model T̃ . Our transformation parameter θ̃ corresponds to the latent “style” vector in MUNIT terminology, which we observed in Figure 2 and Figure 4 parameterizes a diverse set of nuisance transformations without changing the image’s class.
For all MUNIT training we use identical optimization hyperparameters as in the official source code (Adam (Kingma & Ba, 2014) with learning rate 0.0001 and batch size 1). We sample training examples with class balanced sampling, and as per the original implementation we rescale the pixel values between [−1, 1] and apply random horizontal flips as data augmentation. The image reconstruction loss has weight 10, while the adversarial loss, style reconstruction loss, and content reconstruction loss all have weight 1. We disable the domain-invariant perceptual loss. The generator architecture hyperparameters are identical to the “edges→ handbags” experiment from Huang et al. (2018), and the discriminator is also the same except that we use a single scale discriminator instead of 3 scales. For K49-LT we train the MUNIT architectures on the 28 × 28 image inputs for 10, 000 steps. For GTSRB-LT and CIFAR-LT we train on 32× 32 inputs for 140, 000 steps.

heading: B CLASSIFIER TRAINING DETAILS
text: Optimization. For fair comparison, nearly all of our classifier training hyperparameters are identical to those used in the CIFAR experiments of Cao et al. (2019): 200 training epochs with a batch size of 128, optimized by SGD with momentum 0.9 and with weight decay 2×10−4. The initial learning rate is 0.1 and is decayed by a factor of 10 at 160 epochs and further decayed by the same factor at 180 epochs. Only the K49-LT experiments use a slightly modified training schedule of 50 epochs with learning rate decays at 30 and 40 epochs. For Delayed Resampling (DRS) the resampling stage starts at 160 epochs for GTSRB-LT and CIFAR-LT and at 30 epochs for K49-LT.
Data augmentation. For the CIFAR-LT experiments we used random crop (with padding 4) and random horizontal flip (with probability 0.5) on all non-GIT methods. For methods that use GIT, random horizontal flip is first applied to the entire batch. Then we apply the GIT augmentation to half the batch, and the random crop augmentation to the other half.
Since MUNIT training uses random horizontal flip augmentation, we tried adding random horizontal flip augmentation for classifier training in K49-LT and GTSRB-LT experiments but found that it worsened performance on those datasets. This may be because handwritten characters and text on street signs are not actually flip invariant. Classifier training for K49-LT and GTSRB-LT does not use any additional data augmentation, except for the learned augmentations for the GIT methods.
Architecture. Like Cao et al. (2019), we use a family of ResNet (He et al., 2015) architecture implementations designed for CIFAR (Idelbayev, 2018) for all experiments. We use the ResNet20 architecture for the K49-LT experiments and the ResNet32 architecture for the GTSRB-LT and CIFAR-LT experiments.

heading: C FULL EXPERIMENTAL DETAILS AND RESULTS
text: C.1 BASELINES
We use three loss functions for our experiments — the standard cross entropy loss (CE), Focal loss (Lin et al., 2017) and LDAM (Cao et al., 2019). The last two are specialized loss functions designed for imbalanced dataset learning. Following Cao et al. (2019), we choose γ = 1 as the hyper-parameter for Focal loss, and for LDAM loss, the largest enforced margin is chosen to be 0.5.
We couple these loss functions with a variety of training schedules, described below:
• Class balanced reweighting (CB RW) (Cui et al., 2019): Instead of reweighting the loss for a particular training example proportional to the inverse of corresponding class size, we reweight according to the inverse of the effective number of training samples in the
corresponding class:
N ieff = 1− βNi
1− β (3)
where N ieff is the effective number of training examples in class i, N i is true number of training samples for class i, and β is a parameter, which we typically set to 0.9999 for all our experiments.
• Class balanced resampling (CB RS) (Cui et al., 2019): We resample the training examples in a particular class with probability proportional to the inverse of effective number of training samples (see Equation 3) in that class.
• Resampling (RS): This is the regular resampling strategy, where we resample the training examples in a particular class with probability proportional to the inverse of (true) number of training samples in that class.
• Delayed reweighting (DRW) (Cao et al., 2019): We train in a regular way for the initial part of the training, and reweight the loss according to the inverse of the effective number of samples (Equation 3) in a training class only at the last phase of the training. For GTSRBLT and CIFAR-LT, we typically train for 200 epochs, and reweight the loss function starting at 160 epochs.
• Delayed resampling (DRS): Similar to DRW, but we resample examples from class i with a probability inverse to the true number of training examples in class i.
Among all the combinations of loss functions and training strategies, we discover that LDAM + DRS typically does the best, and combining GIT with it gives an additional boost in performance.
C.2 K49-LT
When constructing the synthetic datasets we used one of three transformation families and applied a randomly sampled transformation from the family to each image in the dataset. For rotation, we rotated the raw image by a randomly sampled angle θ ∈ [0, 2π). For background intensity, we replaced the original black background with a randomly sampled pixel value between 0 and 100, where 255 is the maximum intensity. For dilation and erosion, we randomly either applied
dilation with 60% probability or erosion with 40% probability, using OpenCV’s dilate and erode functionality. For dilation we used an n × n kernel of 1’s, where n ∼ Unif({2, 3, 4}), and for erosion we used an m×m kernel of 1’s, where m ∼ Unif({1, 2}). The per class eKLD curves on the K49-LT variants were calculated for a ResNet20 architecture, but to verify that the results are not specific to ResNet we repeated these experiments on a simple CNN, which consists of four blocks of 3 × 3 convolutions, batch normalization, ReLU, and max pooling with stride 2. A final linear layer produces the output logits. Figure 6 shows the resulting per class eKLD for both architectures. We see that classifiers struggle to transfer learned invariances to the tail classes regardless of architecture, and that GIT can help mitigate this problem in both cases.
C.3 GTSRB-LT AND CIFAR-LT
Table 3 and Table 4 present a more comprehensive set of experiments on GTSRB-LT and the two CIFAR-LT benchmarks, comparing how GIT performs with wider combinations of losses and training schedules. Overall we see that GIT works best when paired with a resampling method (such as DRS), and offers less benefit when applied to reweighting schemes or the standard training process. Intuitively, resampling boosts the probability of sampling examples from the small classes, which GIT can then augment, providing the classifier with more diversity for the small classes. Without resampling, the classifier is rarely sees examples from the small classes at all, minimizing the impact that GIT can have. In fact, without resampling, GIT will be applied primarily to images from the larger classes, and we saw in Section 6 that using GIT on larger classes can hurt the performance of the classifier. This is also confirmed on Table 3 and 4, where GIT often hurts the performance for non-resampling training schedules.

Review summaries:
======================= Summary:  This paper studies the problem of how well do neural networks transfer class-agnostic invariances from head classes to tail classes. They found that even a given transformation is class-agnostic, the DNN models still cannot disentangle it from class-specific features, which could partially explain the worse performances on rare classes. To solve this problem, they introduce a GIT method that uses a generative model to augment the tail categories with more diverse samples under certain transformations. It can empirically improve the long-tailed performances and transfer the knowledge of class-agnostic transformations from head to tail. 

The paper investigates if robustness (or "invariance") to nuisance transformations which do not change the class label such as lighting, rotation etc are learned across all classes or if such robustness is sensitive to the class size. The paper demonstrates that such invariances seem not to transfer across classes: ie the classes with fewer examples suffer more. THe paper proposes a generative model (GIT) to "augment" the less frequent classes which, to some degree, remedies this problem. 

The paper investigates if invariances learned by the model transfer across classes. Focussing on class-agnostic nuisance parameters, the interplay between per-class size and invariant representations has been explored. It is suggested that while networks can become invariant to these parameters for classes with many examples, it is unclear if this is also the case for classes with fewer examples. The paper shows this is not true i.e. invariances do not transfer well to small classes, and suggest that improving this can help increase performance on imbalanced datasets. And so, the paper proposes a two step solution to this problem. First, an image-conditional generative model is learned which learns to transform the image such that only the nuisance parameter changes. Secondly, this model for nuisance parameters is used for data augmentation. Using this approach, the authors are able to achieve a significant improvement on standard long-tail datasets.

This paper works on long-tailed or class-imbalanced learning. The authors found that the learned classifier in such a setting cannot effectively transfer the class-agnostic (in)variance in a dataset from the head classes to the tail classes, which causes poor classification performance for the tail classes. The authors thus proposed to learn such class-agnostic (in)variance via a generative model, and then use it to augment the training data of minor classes. The experimental results on several small-scale datasets demonstrate the effectiveness of the proposed method in improving long-tailed or class-imbalanced classification.