<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Is self-supervised learning more robust than supervised learning?</title></titleStmt>
			<publicationStmt>
				<publisher></publisher>
				<date>2022</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10345816</idno>
					<idno type="doi"></idno>
					<title level='j'>Proc ICML Workshop on Pre-training</title>
<idno></idno>
<biblScope unit="volume"></biblScope>
<biblScope unit="issue"></biblScope>					

					<author>Y. Zhong</author><author>H. Tang</author><author>J. Chen</author><author>J. Peng</author><author>Y.-X. Wang</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><p>Our main results consist of two sets of experiments: The first investigates the downstream robustness of pre-trained models towards corruptions of downstream data. The second studies the robustness under pre-training data corruptions. We deliver a set of intriguing new discoveries. We generally observe that CL is consistently more robust than SL to downstream corruptions. On the other hand, contrastive learning on corrupted pre-training data leads to diverging observations depending on the corruption type: CL is more robust to dataset-level corruption than SL, but less so to pixel-and patch-level corruptions.</p><p>To explain why CL models are more robust to downstream corruptions, our analysis of the learning dynamics through feature space metrics reveals that CL yields larger overall and steadily-increasing per-class feature uniformity <ref type="bibr">(Wang &amp; Isola, 2020)</ref> and higher stability than SL. An immediate consequence is an improvement to supervised pre-training's downstream robustness by adding a uniformity regularization term to explicitly promote intra-class variance. As for CL's vulnerability to pre-training data corruption types such as patch shuffling, we hypothesize that the interference with random crop augmentation is the main culprit, as we find switching the order of data corruption and standard augmentations recovers a substantial amount of robustness.</p><p>We summarize our contributions as follows. (1) We design extensive robustness tests to study the behavioral differences of CL and SL systematically. (2) We discover diverging robustness behaviors between CL and SL, and even among different CL algorithms. (3) We offer initial analyses and explanations for such observations, and show a simple way to improve the downstream robustness of supervised learning by encouraging uniformity. We claim our paper as an empirical study. We hope our findings can serve as an initial step to fully understand CL's behaviors beyond accuracy and inspire more future studies to explore such aspects through larger-scale experiments and theoretical analysis.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.">Method</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.1.">Robustness Tests</head><p>Robustness Test I: Downstream data corruption. In this test, the pre-training algorithm is run on the clean version of the pre-training dataset. For a given downstream dataset, we evaluate the pre-trained model's accuracy on its original version and various corrupted versions. This assesses the robustness of the algorithm by looking at the pre-trained model's robustness behaviors.</p><p>Robustness Test II: Pre-training data corruption. This assesses the algorithm's robustness to pre-training data corruptions. We run the pre-training algorithm on the corrupted version of the dataset, and then evaluate the final model's accuracy on either the corrupted test set or the original test set. The test set can be in-domain or out-domain to the train set. Since data corruption destroys certain information by design, the model pre-trained on corrupted data is expected to yield degraded performance than the model pre-trained on the uncorrupted dataset.</p><p>Robustness Metric. In both cases, the robustness is measured by the degradation in accuracy caused by certain data corruption. An algorithm is more robust if the degradation is smaller. Denote D original as the original dataset and D corrupted as the corrupted dataset. We use the same notation for both pre-training and downstream corruptions. For an algorithm Alg &#8712; {CL, SL}, we define</p><p>We use two methods to obtain the test accuracy in the above equation. The first is linear evaluation, where we train a linear classifier on top of the representation learned by the pre-training algorithm on the train split, and then evaluate the classifier on the test split. The second is KNN evaluation. We use the weighted KNN classifier from <ref type="bibr">Wu et al. (2018)</ref>, where the prediction is the exponential-distance weighted average of the K nearest neighbors in the train split of any test data point, measured by the normalized feature vectors. The KNN evaluation effectively leverages a non-parametric classifier, therefore no classifier training is required. Depending on the context, we use either linear or KNN evaluation in our experiments. The essential question we would like to ask is whether &#8710;(CL) is consistently larger or smaller than &#8710;(SL) across different data corruptions.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2.">Types of Data Corruption</head><p>There is a natural hierarchy of data corruptions ranging conceptually from micro-level to macro-level. We will describe the several variations illustrated in Figure <ref type="figure">1</ref>. Note that our data corruption is different from data augmentation. In data augmentation, the corruption is applied randomly on a perimage basis. In our case, a fixed random transformation (e.g., the gamma in gamma distortion or the permutation order in shuffling) is decided first then applied consistently across all the images. We effectively transform the entire train or test dataset with the corruption method.</p><p>Pixel-Level Corruption. &#8226; Synthesized data: Synthesized data is popularizing (e.g., DALL&#8226;E 2 <ref type="bibr">(Ramesh et al., 2022)</ref>) and studied to replace real data <ref type="bibr">(Jahanian et al., 2021)</ref>. We utilize generative methods such as a conditional GAN <ref type="bibr">(Karras et al., 2020)</ref> to generate a synthesized dataset D GAN and replace D original . We can then measure and compare &#8710;(Alg) between these two datasets of different distributions. Oftentimes, the generated distribution is not perfectly aligned with the real distribution; therefore, training with the generative data source may lead to degradation in accuracy of clean data or downstream performance.</p><p>&#8226; Class imbalance: Real-world data often follows a longtail distribution of semantic classes, where head classes have many examples while tail classes have few examples <ref type="bibr">(Kang et al., 2020;</ref><ref type="bibr">Samuel &amp; Chechik, 2021)</ref>. However, benchmark datasets such as CIFAR and ImageNet are curated and class-balanced. We consider the widelyused variant of ImageNet, ImageNet-LT (long-tail) <ref type="bibr">(Liu et al., 2019)</ref>, with maximally 1280 images and minimally 5 images per class. For comparison, we construct ImageNet-UF (uniform) which is a class-balanced subset of ImageNet that contains the same number of images as ImageNet-LT (115K). Then we test whether moving from pre-training on ImageNet-UF to ImageNet-LT leads to different behaviors between CL and SL.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.3.">Experiment Setup</head><p>Datasets. We pre-train on CIFAR-10 ( <ref type="bibr">Krizhevsky &amp; Hinton, 2009)</ref> and ImageNet <ref type="bibr">(Deng et al., 2009)</ref> variants to evaluate the robustness differences between CL and SL methods subject to pre-training data corruptions. We use CIFAR-10/100 <ref type="bibr">(Krizhevsky &amp; Hinton, 2009)</ref>, <ref type="bibr">STL-10 (Coates et al., 2011)</ref>, and two fine-grained classification datasets, Cars <ref type="bibr">(Krause et al., 2013)</ref> and Aircrafts <ref type="bibr">(Maji et al., 2013)</ref>, to analyze the performance of the pre-trained models on the corrupted downstream tasks. For comparable results, we fix the data augmentation for all settings that involve training.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Models and Algorithms.</head><p>We benchmark a variety of self-supervised contrastive algorithms. These methods are carefully-sampled to be representative. They include contrastive learning with negatives (SimCLR-v2 <ref type="bibr">(Chen et al., 2020a;</ref><ref type="bibr">b)</ref>, MoCo-v2 <ref type="bibr">(He et al., 2020;</ref><ref type="bibr">Chen et al., 2020d)</ref>), without negatives (SimSiam <ref type="bibr">(Chen &amp; He, 2021)</ref>, and the momentum counterpart, BYOL <ref type="bibr">(Grill et al., 2020)</ref>), with redundancy reduction (BarlowTwins <ref type="bibr">(Zbontar et al., 2021)</ref>), and contrasting clustering assignments (DeepCluster-v2 <ref type="bibr">(Caron et al., 2020)</ref>, SwAV <ref type="bibr">(Caron et al., 2020)</ref>). We test both CNN (standard ResNet-18/50 <ref type="bibr">(He et al., 2016)</ref>) and Vision Transformer (ViT) <ref type="bibr">(Dosovitskiy et al., 2021)</ref> backbones. For transformer, we leverage pre-trained models on ImageNet <ref type="bibr">(Deng et al., 2009)</ref> from ViT <ref type="bibr">(Dosovitskiy et al., 2021)</ref>, DeiT <ref type="bibr">(Touvron et al., 2021)</ref>, DINO <ref type="bibr">(Caron et al., 2021)</ref>, MoCo-v3 <ref type="bibr">(Chen et al., 2021b)</ref>, and MAE <ref type="bibr">(He et al., 2022)</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.">Results</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1.">CL is more robust to downstream data corruption</head><p>We conduct downstream robustness tests on various datasets with frozen pre-trained ResNet-50 <ref type="bibr">(He et al., 2016)</ref> in Table 1 and ViT <ref type="bibr">(Dosovitskiy et al., 2021)</ref>. The fully fine-tuned ResNet-50 results and the ViT results are deferred to the appendix as the observations are similar. The model checkpoints are obtained from VISSL <ref type="bibr">(Goyal et al., 2021b)</ref> and    The same observation carries over to the larger-scale ImageNet-100 experiment result in Table <ref type="table">3</ref>, where we compare MoCo-v2 (since it appears to be the most robust on CIFAR-10) and Sup in a total of 8 corruption settings.</p><p>MoCo-v2 on average yields a 28.0% degradation, while Sup only degrades 6.65%.</p><p>Dataset-Level Corruption. In Table <ref type="table">4</ref>, MoCo has shown more robustness on average to dataset-level corruption  shows almost no drop while SL drops 6%. We also conduct downstream experiments for this corruption: we test the classification accuracy of the pre-trained representation on CIFAR-100, and make a similar observation.</p><p>Table <ref type="table">5</ref> shows the impact of the other type of dataset-level corruption -the class imbalance. Although there is a gap between the baseline top-1 accuracy of MoCo-v2 and SL, we observe that, the decline of MoCo resulting from pretraining on the long-tail rather than the uniform version is much smaller than SL. In fact, the MoCo performance appears to be insensitive to class balance or imbalance (the top-1 &#8710; is only 0.71%). This is in contrary to SL, which shows a larger drop. The difference is more salient by looking at the low-shot (&lt;20 images per class), medium-shot, and many-shot (&gt;100 images per class) accuracy separately. SL on ImageNet-LT sacrifices the low-shot accuracy for higher many-shot accuracy, whereas MoCo shows insignificant difference among the shots. Our observation is consistent with a contemporary work <ref type="bibr">(Liu et al., 2022)</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.">Analysis</head><p>CL and SL behave differently during training. The robustness discrepancy between CL (e.g., MoCo) and SL There is a growing body of literature on understanding self-supervised learning. <ref type="bibr">Wang &amp; Liu (2021)</ref> decomposes the contrastive objective into alignment (between augmentations) and uniformity (across entire feature space) terms. Uniformity can be thought of as an estimate of the feature entropy, which we leverage as a metric to study the feature space dynamics during training. <ref type="bibr">Wang &amp; Isola (2020)</ref> makes connection between uniformity and the temperature parameter in a contrastive loss, and finds that a good temperature can balance uniformity and tolerance of semantically similar examples. <ref type="bibr">Zhao et al. (2021)</ref> discovers that SSL transferring better than SL can be due to better low-and mid-level features, and the intra-class invariance objective in SL weakens transferability by causing more pre-training and downstream task misalignment. <ref type="bibr">Ericsson et al. (2021)</ref> studies the downstream task accuracy of a variety of pre-trained models and finds that SSL outperforms SL on many tasks. <ref type="bibr">Cole et al. (2022)</ref> investigates the impact of pre-training data size, domain quality, and task granularity on downstream performance. <ref type="bibr">Chen et al. (2021a)</ref> identifies three intriguing properties of contrastive learning: a generalized version of the loss, learning with the presence of multiple objects, and feature suppression induced by competing augmentations. Our work falls into the same line of research that attempts to understand SSL better. However, we investigate from the angle of robustness behavior comparison between SSL/CL and SL.</p><p>Robustness and Data Corruption. The success of learning algorithms is often measured by some form of task accuracy, such as the top-1 accuracy for image classification <ref type="bibr">(Deng et al., 2009;</ref><ref type="bibr">Krizhevsky &amp; Hinton, 2009;</ref><ref type="bibr">Coates et al., 2011;</ref><ref type="bibr">Wah et al., 2011)</ref>, or the mean average precision for object detection <ref type="bibr">(He et al., 2020;</ref><ref type="bibr">Zhong et al., 2020;</ref><ref type="bibr">2021a)</ref>. Beyond accuracy, robustness is another important measure <ref type="bibr">(Hendrycks &amp; Dietterich, 2019)</ref>, and there are benchmarks and metrics proposed for SL <ref type="bibr">(Nado et al., 2021)</ref>. Robustness is more and more studied in SSL settings <ref type="bibr">(Chuang et al., 2022;</ref><ref type="bibr">Goyal et al., 2022)</ref>. <ref type="bibr">Chuang et al. (2022)</ref> tries to improve CL's robustness to noisy positive views. Recent large-scale study reveals that vision models are more robust and fair when pre-trained on uncurated images without supervision <ref type="bibr">(Goyal et al., 2022)</ref>. We use "robustness" to refer to the ability of learning algorithms to cope with systematic train or test data corruptions. Under the supervised setting, deep models are shown to train successfully (albeit not to generalize) under pixel shuffling corruption and random labels, even though they are not human-recognizable anymore <ref type="bibr">(Zhang et al., 2017)</ref>.</p><p>Adversarial robustness <ref type="bibr">(Szegedy et al., 2014;</ref><ref type="bibr">Goodfellow et al., 2015;</ref><ref type="bibr">Madry et al., 2018;</ref><ref type="bibr">Shafahi et al., 2019;</ref><ref type="bibr">Chen et al., 2020c</ref>) is a related but different concept, which refers to the model's ability to defend against adversarial attacks. An adversarial attack <ref type="bibr">(Szegedy et al., 2014;</ref><ref type="bibr">Goodfellow et al., 2015)</ref> is a perceptually indistinguishable perturbation to a single image that fools the model. Adversarial training <ref type="bibr">(Madry et al., 2018;</ref><ref type="bibr">Shafahi et al., 2019)</ref> is a technique to achieve adversarial robustness. Self-supervised perturbation is explored in adversarial attack and training <ref type="bibr">(Naseer et al., 2020;</ref><ref type="bibr">Kim et al., 2020)</ref>. <ref type="bibr">Hendrycks et al. (2019)</ref> shows that SSL models possess better adversarial robustness. <ref type="bibr">Fan et al. (2021)</ref> improves the adversarial robustness transferability of CL. Our definition of robustness differs from adversarial robustness -we use robustness to analyze the tolerance of learning methods to systematic data corruptions (rather than per-image imperceptible perturbation).</p><p>There are many types of data corruptions in prior work. The most common data corruptions, such as random resizing and cropping, flipping, and color jittering, appear as data augmentation in SL and SSL <ref type="bibr">(He et al., 2016;</ref><ref type="bibr">2020;</ref><ref type="bibr">Chen et al., 2020a)</ref>. The learned representation is encouraged to be invariant to such corruptions. <ref type="bibr">Hendrycks &amp; Dietterich (2019)</ref> proposes a set of corruptions complementary to ours. Block shuffling (our image global shuffling) has been used to study what is transferred in transfer learning <ref type="bibr">(Neyshabur et al., 2020)</ref> and as negative views with diminished semantics in contrastive learning <ref type="bibr">(Ge et al., 2021)</ref>. <ref type="bibr">Cole et al. (2022)</ref> tampers data quality in SimCLR and SL training by salt-and-pepper noise, JPEG, resizing, and downsampling, and tests on clean data. We use a different set of data corruptions and test on the corrupted data as well. A recent work <ref type="bibr">(Jahanian et al., 2021</ref>) also studies generative models as an alternative data source for contrastive learning. They focus on comparison with real data, while we emphasize the behavior difference of SSL and SL in response to the generative data source. Feature backward-compatibility <ref type="bibr">(Shen et al., 2020)</ref> is related to our stability analysis of feature dynamics. Recently, <ref type="bibr">Goyal et al. (2021a)</ref> studies the effectiveness of SSL on uncurated class-imbalanced data. <ref type="bibr">Liu et al. (2022)</ref> also notices that SSL tends to be more robust to class imbalance than SL. We bring extra insights over them. We consider both pre-training and downstream robustness and compare CL and SL behaviors, while Goyal et al.</p><p>(2021a) only focuses on downstream and compares dataset scale. Our investigation suggests that pre-train behavior can be opposite to downstream. <ref type="bibr">Liu et al. (2022)</ref> only studies class imbalance, but we consider broader corruptions.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>C. Additional Implementation Details</head><p>Table <ref type="table">C</ref>.3 below lists the experiment configurations for each pre-training robustness table of the main paper. We train our own ResNets <ref type="bibr">(He et al., 2016)</ref> on <ref type="bibr">CIFAR-10 (Krizhevsky &amp; Hinton, 2009)</ref> and ImageNet variants <ref type="bibr">(Deng et al., 2009)</ref>.</p><p>ImageNet-LT/UF are the long-tail and Uniform-subsampled versions. ImageNet-100 is a 100 class subset of full ImageNet-1K. We mainly list Sup and MoCo-v2 <ref type="bibr">(Chen et al., 2020d)</ref> hyper-parameters here. The other CL methods follow their recommended hyper-parameter values in the Solo-Learn package <ref type="bibr">(da Costa et al., 2022)</ref>.  <ref type="bibr">(Chen et al., 2021b)</ref>, the ViT version of MoCo, and Supervised ViT. The results are in Table <ref type="table">D</ref>.1. We find that the MoCo-v3 degradation is larger with patch shuffling, but smaller with gamma distortion. Interestingly, the impact of patch shuffling is much smaller than a CNN (despite the Orig performance gap between ViT and CNN). We suspect this is due to the unique patching and attention network structure of ViT. Essentially, if we do not take into consideration the data augmentation, with the right patch size, the shuffling within a small patch does not affect the learning of ViT much, and the global ordering of patches also does not matter much, because of learned positional embeddings and global attention.    <ref type="table">1</ref> in the main paper and Table <ref type="table">D</ref>.3 above are generated with the KNN evaluation protocol. We also experiment with full fine-tuning on the downstream datasets. The results are in Table <ref type="table">D</ref>.5. Since different pre-trained checkpoints are optimized with different optimizers (SGD for Sup, SimSiam <ref type="bibr">(Chen &amp; He, 2021)</ref>, MoCo-v2 <ref type="bibr">(Chen et al., 2020d)</ref>, and SimCLR-v2 <ref type="bibr">(Chen et al., 2020b)</ref>; LARS <ref type="bibr">(You et al., 2017)</ref> for BYOL <ref type="bibr">(Grill et al., 2020)</ref>, BarlowTwins <ref type="bibr">(Zbontar et al., 2021)</ref>, DeepCluster2, and SwAV <ref type="bibr">(Caron et al., 2020</ref>)), we use SGD (lr 0.002 cosine) for Sup, SimSiam, MoCo, and SimCLR, and AdamW (lr 0.001 cosine) <ref type="bibr">(Loshchilov &amp; Hutter, 2019)</ref> for others during fine-tuning. All models are fine-tuned for 10 epochs. We find this strategy of using different optimizers is able to make the baseline results on original images comparable across methods. We note that fine-tuning drastically improves the accuracy on downstream datasets, while the general observation that CL methods are more robust to downstream corruption than SL still holds, except for BarlowTwins which is slightly worse than SL. Another interesting observation here is that different CL methods actually yield different robustness behaviors, although they are all doing some form of contrastive learning and have similar baseline accuracies.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>D.6. Variance of pre-training results</head><p>We repeat MoCo-v2 on the original CIFAR-10 200ep three times: The KNN evaluation mean and std is 82.44 &#177; 0.18.</p><p>Repeating MoCo-v2 on the global 8x8 shuffling corrupted CIFAR-10 gives KNN evaluation mean and std 59.24 &#177; 0.40.</p><p>The linear evaluation variance is similar. The randomness has a smaller order than the gap between MoCo and Supervised results.</p></div></body>
		</text>
</TEI>
