SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Table 1: Performance comparison of training free approaches on CIFAR-10, CIFAR-100 and TinyImageNet, where  $R^2$  refers to coefficients of determination, and  $\rho$  refers to Spearman correlation coefficients (higher is better). The best results are highlighted in bold.
Dataset	Network	Rotation	ConfScore	Entropy	AgreeScore	ATC	Frechet	Ours
\(R^2\)	ρ	\(R^2\)	ρ	\(R^2\)	ρ	\(R^2\)	ρ	\(R^2\)	ρ	\(R^2\)	ρ	\(R^2\)	ρ
CIFAR 10	ResNet18	0.822	0.951	0.869	0.985	0.899	0.987	0.663	0.929	0.884	0.985	0.950	0.971	0.968	0.990
ResNet50	0.835	0.961	0.935	0.993	0.945	0.994	0.835	0.985	0.946	0.994	0.858	0.964	0.987	0.990
WRN-50-2	0.862	0.976	0.943	0.994	0.942	0.994	0.856	0.986	0.947	0.994	0.814	0.973	0.962	0.988
Average	0.840	0.963	0.916	0.991	0.930	0.992	0.785	0.967	0.926	0.991	0.874	0.970	0.972	0.990
CIFAR 100	ResNet18	0.860	0.936	0.916	0.985	0.891	0.979	0.902	0.973	0.938	0.986	0.888	0.968	0.952	0.988
ResNet50	0.908	0.962	0.919	0.984	0.884	0.977	0.922	0.982	0.921	0.984	0.837	0.972	0.951	0.985
WRN-50-2	0.924	0.970	0.971	0.984	0.968	0.981	0.955	0.977	0.978	0.993	0.865	0.987	0.980	0.991
Average	0.898	0.956	0.936	0.987	0.915	0.983	0.927	0.982	0.946	0.988	0.864	0.976	0.962	0.988
TinyImageNet	ResNet18	0.786	0.946	0.670	0.869	0.592	0.842	0.561	0.853	0.751	0.945	0.826	0.970	0.966	0.986
ResNet50	0.786	0.947	0.670	0.869	0.651	0.892	0.560	0.853	0.751	0.945	0.826	0.971	0.977	0.986
WRNt-50-2	0.878	0.967	0.757	0.951	0.704	0.935	0.654	0.904	0.635	0.897	0.884	0.984	0.968	0.986
Average	0.805	0.959	0.727	0.920	0.650	0.890	0.599	0.878	0.693	0.921	0.847	0.976	0.970	0.987
Figure 3: OOD error prediction versus True OOD error on CIFAR-10 with ResNet50. We compare the performance of Dispersion Score with that of ProjNorm and Fréchet via scatter plots. Each point represents one dataset under certain corruption and certain severity, where different shapes represent different types of corruption, and darker color represents the higher severity level.
the learning rate of  $10^{-3}$ , cosine learning rate decay [Loshchilov and Hutter, 2016], a momentum of 0.9 and a batch size of 128 to train the model.
The compared methods. We consider 7 existing methods as benchmarks for predicting OOD error: Rotation Prediction (Rotation) [Deng et al., 2021], Averaged Confidence (ConfScore) [Hendrycks and Gimpel, 2016], Entropy [Guillory et al., 2021], Agreement Score (AgreeScore) [Jiang et al., 2021], Averaged Threshold Confidence (ATC) [Garg et al., 2022], AutoEval (Fréchet) [Deng and Zheng, 2021], and ProjNorm [Yu et al., 2022]. Rotation and AgreeScore predict OOD error from the view of unsupervised loss constructed by generating rotating instances and measuring output agreement of two independent models, respectively. ConfScore, Entropy, and ATC formulate scores by model predictions. ProjNorm measures the parameter-level difference between the models fine-tuned on train and OOD test data respectively, while Fréchet quantifies the distribution difference in the feature space between the training and test datasets. We present the related works in Appendix B.
Can Dispersion score outperform existing training-free approaches? In Table 1, we present the performance of OOD error estimation on three model architectures and three datasets. We find that Dispersion Score dramatically outperforms existing training-free methods. For example, averaged across three architectures on TinyImageNet, our method leads to an increase of the  $R^2$  from 0.847 to 0.970 – a  $14.5\%$  of relative improvement. In addition, Dispersion Score achieves consistently high performance over the three datasets with a  $R^2$  higher than 0.950, while scores of other approaches such as Rotation varying from 0.787 to 0.924 are not stable. We observe a similar phenomenon on  $\rho$ , where the Entropy method achieves performance that is ranging from 0.842 to 0.994, while the performance of our method fluctuates around 0.988.
Table 2: Performance comparison between ProjNorm [Yu et al., 2022] and our Dispersion score on CIFAR-10, CIFAR-100 and TinyImageNet, where  $R^2$  refers to coefficients of determination,  $\rho$  refers to Spearman correlation coefficients (higher is better), and  $T$  refers to average evaluation time (lower is better). The best results are highlighted in bold.
Dataset	Network	ProjNorm	Ours
\( R^2 \)	\( \rho \)	T	\( R^2 \)	\( \rho \)	T
CIFAR 10	ResNet18	0.936	0.982	179.616	0.968	0.990	10.980
ResNet50	0.944	0.989	266.099	0.987	0.990	11.259
WRN-50-2	0.961	0.989	575.888	0.962	0.988	11.017
Average	0.947	0.987	326.201	0.972	0.990	11.085
CIFAR 100	ResNet18	0.979	0.980	180.453	0.952	0.988	6.997
ResNet50	0.988	0.991	262.831	0.953	0.985	11.138
WRN-50-2	0.990	0.991	605.616	0.980	0.991	12.353
Average	0.985	0.987	349.63	0.962	0.988	10.163
TinyImageNet	ResNet18	0.970	0.981	182.127	0.966	0.986	7.039
ResNet50	0.979	0.987	264.651	0.977	0.990	13.938
WRN-50-2	0.965	0.983	590.597	0.968	0.986	11.235
Average	0.972	0.984	345.792	0.970	0.987	10.737
(a) ResNet18
(b) ResNet-50
Figure 4: Prediction performance  $R^2$  vs. sample size of OOD data (subsets of CIFAR-10C) with (a) ResNet18 and (b) ResNet50.
Dispersion score is superior to ProjNorm. In Table 2, we compare our method to the recent state-of-the-art method - ProjNrom [Yu et al., 2022] in both prediction performance and computational efficiency. The results illustrate that Dispersion Score could improve the prediction performance over ProjNorm with a meaningful margin. For example, with trained models on CIFAR-10 dataset, using Dispersion score achieves a  $R^2$  of 0.953, much higher than the average performance of ProjNorm as 0.873. On CIFAR-100, our method also achieves comparable (slightly better) performance with ProjNorm (0.961 vs. 0.948). Besides, Dispersion score obtains huge advantages to ProjNorm in computational efficiency. Using WRN-50-2, ProjNorm takes an average of 575 seconds for estimating the performance of each OOD test dataset, while our method only requires 11 seconds. Since the computation of Dispersion score does not needs to update model parameters or utilize the training data, our method enables to predict OOD error with large-scale models trained on billions of images.
To further analyze the advantage of our method, we present in Figure 3 the scatter plots for Fréchet, ProjNorm and Dispersion Score on CIFAR-10C with ResNet50. From the figure, we find that Dispersion Score estimates OOD errors linearly w.r.t. true OOD errors in all cases. In contrast, we observe that those methods based on distribution difference tends to fail when the classification error is high. This phenomenon clearly demonstrates the reliable and superior performance of the Dispersion score in predicting generalization performance under distribution shifts.
4.3 Flexibility in OOD data
In previous analysis, we show that Dispersion score can outperform existing methods on standard benchmarks, where the OOD test datasets contain sufficient instances and have a balanced class distribution. In reality, the unlabeled OOD data are naturally imperfect, which may limit the performance of predicting OOD error. In this part, we verify the effectiveness of our method with long-tailed data and small data, compared to ProjNorm [Yu et al., 2022].
Table 3: Summary of prediction performance on Imbalanced CIFAR-10C and CIFAR-100C [Hendrycks and Dietterich, 2019], where  $R^2$  refers to coefficients of determination,  $\rho$  refers to Spearman correlation coefficients (higher is better), and  $T$  refers to average evaluation time (lower is better). The best results are highlighted in bold. More results can be found in Appendix D.
Dataset	Network	ProjNorm	Ours
\( R^2 \)	\( \rho \)	T	\( R^2 \)	\( \rho \)	T
CIFAR 10	ResNet18	0.799	0.968	204.900	0.959	0.982	2.076
ResNet50	0.897	0.980	430.406	0.968	0.982	3.295
WRN-50-2	0.922	0.978	561.611	0.932	0.978	2.970
Average	0.873	0.973	398.972	0.953	0.980	2.780
CIFAR 100	ResNet18	0.886	0.968	210.05	0.941	0.982	1.864
ResNet50	0.980	0.988	433.860	0.956	0.982	2.974
WRN-50-2	0.978	0.982	768.883	0.986	0.994	3.242
Average	0.948	0.980	470.931	0.961	0.986	2.693
Class imbalance. We first evaluate the prediction performance under class imbalanced setting. In particular, given a trained model, we aim to estimate its balanced accuracy under distribution shift while we only have access to a long-tailed test data, where a few classes (majority classes) occupy most of the data and most classes (minority classes) are under-represented. We conduct experiments on CIFAR-10C and CIFAR-100C with imbalance rate 100.
Our results in Table 3 show that Dispersion Score achieves better performance than ProjNorm [Yu et al., 2022] under class imbalance. For example, our approach achieves an average  $R^2$  of 0.953 on CIFAR-10C with 2.780 seconds, while ProjNorm obtains an  $R^2$  of 0.873 and takes 398.972 seconds. In addition, the performance of our method is more stable across different model architectures and datasets with the  $R^2$  ranging from 0.932 to 0.986 than ProjNorm (0.799 - 0.980). Overall, Dispersion score maintains reliable and superior performance even when the OOD test set are class imbalanced.
Sampling efficiency. During deployment, it can be challenging to collect instances under a specific distribution shift. However, existing state-of-the-art methods [Yu et al., 2022] normally require a sufficiently large test dataset to achieve meaningful results in predicting OOD error. Here, we further validate the sampling efficiency of Dispersion score, compared with ProjNorm.
Figure 4 presents the performance comparison between Dispersion Score and ProjNorm on subsets of CIFAR10C with various sample sizes. The results show that our method can achieve excellent performance even when only 50 examples are available in the OOD data. In contrast, the performance of ProjNorm decreases sharply with the decrease in sample size. The phenomenon shows that Dispersion score is more efficient in exploiting the information of OOD instances.
4.4 Intra-class compactness Vs Inter-class dispersion
In Section 3, we empirically show that feature separability is naturally tied with the final accuracy and propose an effective score based on inter-class dispersion. However, the connection between intra-class compactness and generalization performance is still a mystery. In this analysis, we show that compactness is not a good indicator of OOD accuracy. Specifically, we define the compactness score:
$$
S (\tilde {\mathcal {D}}) = - \log \frac {\sum_ {j = 1} ^ {k} \sum_ {i = 1} ^ {m _ {j}} | | \pmb {z} _ {i} - \tilde {\pmb {\mu}} _ {j} | | ^ {2}}{n - k}
$$
where  $\tilde{\mu}_j$  denotes the centroid of the cluster  $j$  that the instance  $z_i$  belongs to. Therefore, the compactness score can measure the clusterability of the learned features, i.e., the average distance between each instance and its cluster centroid. Intuitively, a high compactness score may correspond to a
well-separated feature distribution, which leads to high test accuracy. Surprisingly, in Figure 5, we find that the compactness score is largely irrelevant to the final OOD error, showing that it is not an effective indicator for predicting generalization performance under distribution shifts.
Figure 5: Compactness vs. test error on CIFAR-10C with ResNet50.
4.5 The importance of the weight
As introduced in Section 3, Dispersion Score can be viewed as a weighted arithmetic mean of the distance from centers of each class to the center of the whole samples in the feature space, where the weight is the total number of samples in the corresponding class. To verify the importance of the weight in long-tailed setting, we consider a variant that removes the weight:
$$
S (\tilde {\mathcal {D}}) = \frac {1}{k - 1} \sum_ {j = 0} ^ {k} \varphi (\bar {\boldsymbol {\mu}}, \tilde {\boldsymbol {\mu}} _ {j}).
$$
The results are shown in Table 4, where we compare performances of Dispersion score and the variant without weight respectively under imbalanced CIFAR-10C and CIFAR-100C with ResNet10 and ResNet50. From this table, we could observe that the weight enhances the robustness significantly in long-tail conditions.
Table 4: Summary of prediction performance on Imbalanced CIFAR-10C and CIFAR-100C. The best results are highlighted in bold.
Dataset	Network	w/o Weights	w/ Weights
\( R^2 \)	ρ	\( R^2 \)	ρ
CIFAR 10	ResNet18	0.675	0.930	0.959	0.982
ResNet50	0.748	0.948	0.968	0.982
Average	0.712	0.939	0.978	0.990
CIFAR 100	ResNet18	0.595	0.838	0.941	0.982
ResNet50	0.395	0.733	0.956	0.982
Average	0.494	0.785	0.952	0.986
4.6 K-means vs. Pseudo labels.
While our Dispersion score derived from pseudo labels has demonstrated strong promise, a question arises: can a similar effect be achieved by alternative clustering methods? In this ablation, we show that labels obtained by K-means [Lloyd, 1982, MacQueen, 1967] does not achieve comparable performance with pseudo labels obtained from the trained classifier. In particular, we allocate instances into clusters by using K-means instead of pseudo labels from the classifier.
We present the performance comparison of our method and the variant of K-means in Figure 6. The results show that our Dispersion score performs better than the K-means variant and the gap is enlarged with more classes. On the other hand, the variant of K-means does not require a
Figure 6: Compare with K-means.
classifier, i.e., the linear layer in the trained model, which enables to evaluate the OOD performance of representation learning methods, e.g., self-supervised learning.
In this paper, we introduce Dispersion score, a simple yet effective indicator for predicting the generalization performance on OOD data without labels. We show that Dispersion score is strongly correlated to the OOD error and achieves consistently better performance than previous methods under various distribution shifts. Even when the OOD datasets are class imbalanced or have limit number of instances, our method maintains a high prediction performance, which demonstrates the strong flexibility of dispersion score. This method can be easily adopted in practical settings. It is straightforward to implement with trained models with various architectures, and does not require access to the training data. Thus, our method is compatible with large-scale models that are trained on billions of images. We hope that our insights inspire future research to further explore the feature separability for predicting OOD error.
This research is supported by the Ministry of Education, Singapore, under its Academic Research Fund Tier 1 (RG13/22). Hongxin Wei gratefully acknowledges the support of Center for Computational Science and Engineering at Southern University of Science and Technology for our research. Lei Feng is supported by the National Natural Science Foundation of China (Grant No. 62106028), Chongqing Overseas Chinese Entrepreneurship and Innovation Support Program, Chongqing Artificial Intelligence Innovation Center, CAAI-Huawei MindSpore Open Fund, and Openl Community (https://openi.pcl.ac.cn).
Shai Ben-David, John Blitzer, Koby Crammer, and Fernando Pereira. Analysis of representations for domain adaptation. Advances in Neural Information Processing Systems, 19, 2006.
Yoshua Bengio, Aaron Courville, and Pascal Vincent. Representation learning: A review and new perspectives. IEEE transactions on Pattern Analysis and Machine Intelligence, 35(8):1798-1828, 2013.
Mahalanobis Prasanta Chandra et al. On the generalised distance in statistics. In Proceedings of the National Institute of Sciences of India, volume 2, pages 49-55, 1936.
Yang Chen, Yu Wang, Yingwei Pan, Ting Yao, Xinmei Tian, and Tao Mei. A style and semantic memory mechanism for domain generalization. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 9164-9173, 2021.
Ciprian A Corneanu, Sergio Escalera, and Aleix M Martinez. Computing the testing error without a testing set. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2677-2685, 2020.
Weijian Deng and Liang Zheng. Are labels always necessary for classifier accuracy evaluation? In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 15069-15078, 2021.
Weijian Deng, Stephen Gould, and Liang Zheng. What does rotation prediction tell us about classifier accuracy under varying testing environments? In International Conference on Machine Learning, pages 2579-2589. PMLR, 2021.
Pierre A Devijver and Josef Kittler. Pattern recognition: A statistical approach. Prentice hall, 1982.
DC Dowson and BV666017 Landau. The frechet distance between multivariate normal distributions. Journal of Multivariate Analysis, 12(3):450-455, 1982.
Richard O Duda, Peter E Hart, et al. Pattern classification. John Wiley & Sons, 2006.
Keinosuke Fukunaga. Introduction to statistical pattern recognition. Elsevier, 2013.
Yaroslav Ganin and Victor Lempitsky. Unsupervised domain adaptation by backpropagation. In International Conference on Machine Learning, pages 1180-1189. PMLR, 2015.
Rui Gao and Anton Kleywegt. Distributionally robust stochastic optimization with Wasserstein distance. Mathematics of Operations Research, 2022.
Frederick D Garber and Abdelhamid Djouadi. Bounds on the bayes classification error based on pairwise risk functions. IEEE Transactions on Pattern Analysis and Machine Intelligence, 10(2): 281-288, 1988.
Saurabh Garg, Sivaraman Balakrishnan, Zachary C Lipton, Behnam Neyshabur, and Hanie Sedghi. Leveraging unlabeled data to predict out-of-distribution performance. arXiv preprint arXiv:2201.04234, 2022.
Arthur Gretton, Karsten Borgwardt, Malte Rasch, Bernhard Scholkopf, and Alex Smola. A kernel method for the two-sample-problem. Advances in Neural Information Processing Systems, 19, 2006.
Yaodong Yu, Zitong Yang, Alexander Wei, Yi Ma, and Jacob Steinhardt. Predicting out-of-distribution error with the projection norm. arXiv preprint arXiv:2202.05834, 2022.
Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. In BMVC, 2016.
Werner Zellinger, Thomas Grubinger, Edwin Lughofer, Thomas Natschlager, and Susanne Saminger-Platz. Central moment discrepancy (cmd) for domain-invariant representation learning. arXiv preprint arXiv:1702.08811, 2017.
Zhaowei Zhu, Yiwen Song, and Yang Liu. Clusterability as an alternative to anchor points when learning with noisy labels. In International Conference on Machine Learning, pages 12912-12923. PMLR, 2021.
Zhaowei Zhu, Zihao Dong, and Yang Liu. Detecting corrupted labels without training a model to predict. In International Conference on Machine Learning, pages 27412-27427. PMLR, 2022.
Fuzhen Zhuang, Xiaohu Cheng, Ping Luo, Sinno Jialin Pan, and Qing He. Supervised representation learning: Transfer learning with deep autoencoders. In Twenty-Fourth International Joint Conference on Artificial Intelligence, pages 4119-4125, 2015.
A The calculation of Dispersion Score
Our proposed approach, Dispersion Score, can be calculated as shown in Algorithm 1.
Algorithm 1 OOD Error Estimation via Dispersion Score
Input: OOD test dataset  $\tilde{\mathcal{D}} = \{\tilde{x}_i\}_{i=1}^m$ , a trained model  $f$  (feature extractor  $f_g$  and classifier  $f_\omega$ )  
Output: The dispersion score  
for each OOD instance  $\tilde{x}_i$  do  
    Obtain feature representation via  $\tilde{z}_i = f_g(\tilde{x}_i)$ .  
    Obtain pseudo labels via  $\tilde{y}_i' = \arg \max f_\omega(z_i)$   
end for  
Calculate cluster centroids  $\{\tilde{\mu}_j\}_{j=1}^k$  using pseudo labels  $\tilde{y}_i'$ , with  $\tilde{\mu}_j = \frac{1}{m_j} \sum_{i=1}^{m_j} z_i \cdot \mathbb{1}\{\tilde{y}_i' = j\}$   
Calculate the feature center of all instances by  $\bar{\mu} = \frac{1}{m} \sum_{i=1}^{m} z_i$   
Calculate Dispersion Score  $S(\tilde{\mathcal{D}})$  via Equation (4)
Predicting generalization. Since the generalization capability of deep networks under distribution shifts is a mysterious desideratum, a surge of researches pay attention to estimate the generalization capability from two directions.
1) Some works aim to measure generalization gap between training and test accuracy with only training data [Corneanu et al., 2020, Jiang et al., 2019, Neyshabur et al., 2017, Unterthiner et al., 2020, Yak et al., 2019, Martin and Mahoney, 2020]. For example, the model-architecture-based method [Corneanu et al., 2020] summarizes the persistent topological map of a trained model to formulate its inner-working function, which represents the generalization gap. Margin distribution [Jiang et al., 2019] measures the gap by gauging the distance between training examples and the decision boundary. However, those methods are designed for the identical distribution between the training and test dataset, being vulnerable to distribution shift.
2) Some studies try to estimate generalization performance on a specific OOD test dataset without annotation during evaluation. Many of them utilize softmax outputs of the shifted test dataset to form a quantitative indicator of OOD error [Guillory et al., 2021, Jiang et al., 2021, Guillory et al., 2021, Garg et al., 2022]. However, those methods are unreliable across diverse distribution shifts due to the overconfidence problem [Wei et al., 2022]. Another popular direction considers the negative correlation between distribution difference and model's performance in the space of features [Deng and Zheng, 2021] or parameters [Yu et al., 2022]. Nevertheless, common distribution distances practically fail to induce stable error estimation under distribution shift [Guillory et al., 2021], and those methods are usually computationally expensive. Unsupervised loss such as agreement among multiple classifiers [Jiang et al., 2021, Madani et al., 2004, Platanios et al., 2016, 2017] and data augmentation [Deng et al., 2021] is also employed for OOD error prediction, which requires specific model structures during training. In this work, we focus on exploring the connection between feature separability and generalization performance under distribution shift, which is training-free and does not have extra requirements for datasets and model architectures.
Exploring Feature distribution in deep learning. In the literature, feature distribution has been widely studied in domain adaptation [Ben-David et al., 2006, Pan et al., 2010, Zhuang et al., 2015, Tzeng et al., 2017], representation learning [Bengio et al., 2013, HaoChen et al., 2021, Ming et al., 2023, Huang et al., 2021], OOD generalization [Li et al., 2018, Chen et al., 2021, Wang et al., 2021], and noisy-label learning [Zhu et al., 2021, 2022]. Domain adaptation methods usually learn a domain-invariant feature representation by narrowing the distribution distance between the two domains with certain criteria, such as maximum mean discrepancy (MMD) [Pan et al., 2010], Kullback-Leibler (KL) divergence [Zhuang et al., 2015], central moment discrepancy (CMD) [Zellinger et al., 2017], and Wasserstein distance [Lee and Raginsky, 2017]. InfoNCE [Huang et al., 2021] shows a key factor of contrastive learning that the distance between class centers should be large enough. In learning with noisy labels, it has been shown that the feature clusterability can be used to estimate the transition matrix [Zhu et al., 2021]. To the best of our knowledge, we are the first to analyze the connection between feature separability and the final accuracy on OOD data.
C Sensitivity analysis: pseudo labels
Here, we conduct a sensitivity analysis by using ground-truth labels in our method. Table 5 illustrates that the performance with pseudo labels is comparable with the performance using ground-truth labels. This phenomenon is consistent with the previous method - ProjNorm [Yu et al., 2022], shown in Table 8 of their paper. The reason behind this could be that the trained model is capable of identifying certain semantic information from most corrupted examples, thereby retaining their representations in a cluster. Thus, the separability of feature clusters can serve as an indicator of the final prediction performance for corruption perturbations. Additionally, we provide a failure case of feature clusters separability for adversarial perturbations in Appendix F.