Understanding the Effect of the Long Tail on Neural Network Compression
Network compression is now a mature sub-field of neural network research:
over the last decade, significant progress has been made towards reducing the
size of models and speeding up inference, while maintaining the classification
accuracy. However, many works have observed that focusing on just the overall
accuracy can be misguided. E.g., it has been shown that mismatches between the
full and compressed models can be biased towards under-represented classes.
This raises the important research question, can we achieve network compression
while maintaining "semantic equivalence" with the original network? In this
work, we study this question in the context of the "long tail" phenomenon in
computer vision datasets observed by Feldman, et al. They argue that
memorization of certain inputs (appropriately defined) is essential to
achieving good generalization. As compression limits the capacity of a network
(and hence also its ability to memorize), we study the question: are mismatches
between the full and compressed models correlated with the memorized training
data? We present positive evidence in this direction for image classification
tasks, by considering different base architectures and compression schemes.
Harvey Dam, Vinu Joseph, Aditya Bhaskara, Ganesh Gopalakrishnan, Saurav Muralidharan, Michael Garland
# Understanding the Effect of the Long Tail on Neural Network Compression

###### Abstract

Network compression is now a mature sub-field of neural network research: over the last decade, significant progress has been made towards reducing the size of models and speeding up inference, while maintaining the classification accuracy. However, many works have observed that focusing on just the overall accuracy can be misguided. E.g., it has been shown that mismatches between the full and compressed models can be biased towards under-represented classes. This raises the important research question, _can we achieve network compression while maintaining "semantic equivalence" with the original network?_ In this work, we study this question in the context of the "long tail" phenomenon in computer vision datasets observed by Feldman (2020). They argue that _memorization_ of certain inputs (appriately defined) is essential to achieving good generalization. As compression limits the capacity of a network (and hence also its ability to memorize), we study the question: are mismatches between the full and compressed models correlated with the memorized training data? We present positive evidence in this direction for image classification tasks, by considering different base architectures and compression schemes.

## 1 Introduction

A large body of research has been devoted to developing methods that can reduce the size of deep neural network (DNN) models considerably without affecting the standard metrics such as top-1 accuracy. Despite these advances, there are still _mismatches_ between the models, i.e., inputs that are classified differently by the original and compressed models. Furthermore, there has been evidence that compression can affect the accuracy of certain classes more than others (leading to fairness concerns, e.g., see Hooker et al. (2019); Joseph et al. (2020)).

Many works have tried to combat mismatches by using techniques such as reweighting misclassified examples Lin et al. (2017), using multi-part loss functions Joseph et al. (2020) that incorporate ideas from knowledge-distillation Hinton et al. (2015) to induce better _alignment_ between the original and compressed models. Joseph (2021) demonstrated that inducing alignment also improves metrics such as fairness across classes and similarity of attribution maps. In spite of this progress, all the known techniques for model compression result in a non-negligible number of mismatches. This leads to some natural questions, _can we develop a systematic understanding about these mismatches? Are a certain number of mismatches unavoidable and an inherent consequence of underparameterization?_ These questions are important not only for vision models, but also in other domains such as language models Brown et al. (2020), autonomous driving Bojarski et al. (2016), health-care Ravi et al. (2016) and finance Tran & Tran (2020).

Our goal in this work is to address these questions using the idea that real datasets have a "long tail" property, as hypothesized in Feldman (2020); Feldman & Zhang (2020). Informally, their thesis is
that real datasets have many examples that are "atypical," and unless their labels are _memorized,_ we incur high test loss. Figure 1 shows some such atypical examples. This thesis has a direct implication for network compression: if the compressed network does not have sufficient capacity to memorize the atypical examples, it must have a significant mismatch with the original model! Our goal in this work is to explore this connection by asking, _is there a strong correlation between the mismatches that arise after model compression, and the long-tail portion of the data distribution?_

To answer this question, we first compute the _influence_, as defined by Feldman & Zhang (2020), of each training example on the model's accuracy on test examples, as well as on training examples, in the CIFAR-10 dataset Krizhevsky et al. (2009). We then compress models using a variety of compression algorithms and perform statistical analysis on the influence values and mismatched predictions between the reference model and the compressed model. Our experiments are based on the observation that if training and test sets are drawn from the same distribution, then memorizing highly influential, atypical, training examples improves accuracy on test examples that are similar to them and also atypical. By observing the connection between these highly influenced test examples and a compressed model's misclassified test examples, we can characterize the misclassified examples in terms of memorization.

## 2 Definitions and Methodology

### Measuring Mismatch or Misalignment

Comparing DNN models is a well-known challenge in machine learning (ML) systems. In the context of model compression, it is natural to compare models in terms of their "functional" behavior. This leads to the definition of _compression impacted exemplars_ presented below. We remark that other metrics are also very useful, e.g., understanding whether the models "use the same features" for classification; obtaining concrete metrics that can capture such semantic information is an active direction of research.

The simplest measure of misalignment among models is in terms of their predictions. Hooker et al. (2019) introduced the notion of **compression impacted exemplars (CIEs)**: test examples that the

Figure 1: CIFAR10 examples corresponding to extreme influence values. (a, d) Train and test examples at the most negative influence value, (b, e) at the lowest magnitude influence value, and (c, f) at the most positive influence value. In general, we expect positive influence to correspond to _helpful_ examples, near-zero influence to correspond to unremarkable examples, and negative influence to correspond to unhelpful examples.
compressed and uncompressed models classify _differently_. Having a near-zero number of CIEs indicates that the models are "functionally" equivalent. We will focus on the CIEs in our experiments, and also divide them into subtypes. Note that CIEs are more important when the reference model makes the _correct_ (agreeing with ground truth) prediction, because this means that the compressed models get those examples wrong. We denote such examples by _CIE-U_. CIEs that are classified correctly by the compressed model are denoted _CIE-C_.

### Influence and Memorization of Training Data

As outlined earlier, Feldman (2020) makes the case that memorization is _necessary_ for achieving close-to-optimal generalization error in real datasets. Specifically, when the data distribution is long-tailed, i.e., when rare and atypical instances make up a significant fraction of the data, memorizing these instances is unavoidable in order to obtain high accuracy.

Feldman & Zhang (2020) developed approaches for empirically evaluating this "long tail" theory. The starting point for such evaluation is examining which training examples are memorized and the utility of the memorized examples as a whole. We recall their definitions of _influence_ and _memorization_: For a training algorithm \(\mathcal{A}\) operating on a training dataset \(S=\left((x_{1},y_{1}),\cdots,(x_{|S|},y_{|S|})\right)\) and test dataset \(T=\left((x^{\prime}_{1},y^{\prime}_{1}),\cdots,(x^{\prime}_{|T|},y^{\prime}_{| T|})\right)\) the amount of influence of \((x_{i},y_{i})\in S\) on \((x^{\prime}_{j},y^{\prime}_{j})\in T\) is the difference between the accuracy of classifying \((x^{\prime}_{j},y^{\prime}_{j})\) after training with and without \((x_{i},y_{i})\). Formally,

\[\mathtt{inf1}(\mathcal{A},S,i,j):=\Pr_{h\leftarrow\mathcal{A}(S)}\left[h\left( x^{\prime}_{j}\right)=y^{\prime}_{j}\right]\,-\Pr_{h\leftarrow\mathcal{A}(S^{ \wedge i})}\left[h\left(x^{\prime}_{j}\right)=y^{\prime}_{j}\right] \tag{1}\]

where \(S^{\setminus i}\) denotes the dataset \(S\) with \((x_{i},y_{i})\) removed and probability is taken over the randomness of the algorithm \(\mathcal{A}\) such as random initialization. Memorization is defined as the influence of training examples on training examples, i.e. when \(S=T\) and \((x_{i},y_{i})=(x^{\prime}_{j},y^{\prime}_{j})\). This definition captures and quantifies the intuition that an algorithm memorizes the label \(y_{i}\) if its prediction at \(x_{i}\) based on the rest of the dataset changes significantly once \((x_{i},y_{i})\) is added to the dataset.

Using the definition directly, calculating the influence requires training \(\mathcal{A}(S^{\setminus i})\) on the order of \(1/\sigma^{2}\) times for every example, \(\sigma^{2}\) being the variance of the estimation. As a result, this approach requires \(\Omega(|S|/\sigma^{2})\) training runs which translates into millions of training runs needed to achieve \(\sigma\leq 0.1\) on a dataset with \(|S|=50,000\) examples. To avoid this blow-up, Feldman & Zhang (2020) provide

Figure 2: We collect the estimated influence of each training example on each test example is collected in a matrix \(I\), shaped (number of test examples \(\times\) number of training examples). The \((i,j)\)th element is the estimated influence of training example \(j\) on test example \(i\).
an estimation algorithm that uses only \(O(1/\sigma^{2})\) training steps in total. We adopt their algorithm in our experiments.

## 3 Experiments

Although individual influence values are bounded in \([-1,1]\), influence values on examples from natural data tend to be roughly normally distributed and close to zero (Figure 3). Furthermore, there are usually much fewer CIEs than non-CIEs in a test set. Thus, using the Student's t-test to compare the influences of different sets of examples is reasonable. Using the estimated influence and memorization of CIFAR-10 training examples from Feldman (2020), along with the CIEs that resulted from compression, we compared the mean influence on CIEs versus those on examples that were not CIEs. A t-test was done for each loss functions and CIE types. These experiments are summarized in Algorithm 1, in which \(\odot\) is element-wise multiplication and \(\odot\) is element-wise division.

We implemented Algorithm 1 in Python using PyTorch 1.13 and estimated the influence and memorization of CIFAR10 examples in DenseNet, ResNet-20, ResNet-56, and ResNext-20 over 100 trials each. For each trial, we masked out a random 30% of the training set and trained for 300 epochs, after which we evaluated correctness on the model using parameters that achieved the highest test accuracy. We compressed ResNet-56 using parameterized loss functions introduced in Joseph et al. (2020) and identified the CIEs that resulted from each loss function.

Our main results are in Figure 4, which shows the test statistics that resulted from performing the t-test using the baseline loss function in Group Sparsity and using the parameterized loss functions in Joseph et al. (2020). (We report CIE counts in Figure 6.) Compressing while using any loss

Figure 3: Histograms of estimated mean influence on CIFAR10 test examples across training examples, i.e. the distribution of \((\sum_{j}I_{i,j})\odot|S|\). Note the logarithmic vertical scale. Almost all training examples have close to 0 influence across the test set. The minority that influences the test set at all do not affect accuracy more than about \(10^{-4}\).
function tested resulted in some positive test statistic, with two loss functions resulting in p-value \(\leq 0.05\). One of those, SoftAdapt Heydari et al. (2019), also happened to achieve the lowest number of CIEs. In general, this indicates that CIEs tend to be unusually highly influenced, and expected to be similar to highly influential, atypical training examples.

## 4 Conclusions

This paper has presented a novel method for understanding the residual impact of label preserving neural network compression. We have discovered that the label mismatches of the compressed model occurred where the classification accuracy of data points were most affected by the presence or absence of training examples. With this initial understanding in place, we envision a number of directions to expand on this idea by confirming this behavior on larger datasets such as ImageNet Deng et al. (2009) and extending this to large language models' OpenAI (2021) memorization of irrelevant text data such as social security numbers. We intend to extend this analysis to help debug compression (sparsity and quantization) induced classification mismatches in privacy preserving inference frameworks that we have recently developed Gouert et al. (2023b;a).

Figure 4: T-test results between the mean difference between influence on CIEs and on non-CIEs. Tests that were significant with p-value \(\leq 0.05\) are marked with *. The t-statistic reflects the number of CIEs that resulted from compression, with the loss functions that resulted in fewer CIEs exhibiting less influence magnitude among them.