Benchmarking Robustness to Natural Distribution Shifts for Facial Analysis
Abstract
During the deployment of machine learning models, performance degradation can occur compared to the training and validation data.
This generalization gap can appear for a variety of reasons and be particularly critical in applications where certain groups of people are disadvantaged by the outcome, e.g. facial analysis.
Literature provides a vast amount of methods to either perform robust classiﬁcation under distribution shifts or at least to express the uncertainty caused by the shifts.
However, there is still a need for data that exhibit different natural distribution shifts considering speciﬁc subgroups to test these methods.
We use a balanced dataset for facial analysis and introduce subpopulation shifts, spurious correlations, and subpopulation-speciﬁc label noise.
This forms our basis to investigate to what extent known approaches for calibrating neural networks remain reliable under these speciﬁed shifts.
Each of the modiﬁcations leads to performance degradation, but the combination of ensembles and temperature scaling is particularly useful to stabilize the calibration over the shifts.
Introduction
Machine Learning is a central tool for many tasks in the area of computer vision and facial analysis.
However, most approaches are evaluated on data that are identically and independently distributed (i.i d.).
This i.i.d.
assumption often cannot be guaranteed during deployment.
Thus, a relatively wide range of possible shifts between training and inference can occur that have a detrimental effect on the generalization performance.
This can be particularly important in areas where predictions of machine learning systems have a direct effect on humans, as it is the case with facial analysis.
Subpopulations may be underrepresented in the training data compared to the overall population [9, 16] or there may be spurious correlations between subpopulations and labels during training that have no real causal relationship [1, 15].
Since this poses a signiﬁcant challenge to the development of real-world machine learning and pervades all areas and applications of machine learning, efforts have been made to mitigate this problem [1, 15, 4, 12, 11].
Furthermore, it is also desirable to get well-calibrated uncertainty estimates, that are reliable across shifts such that we can at least determine when to trust the predictions of the model [13, 3].
In general, however, we need data sets that go beyond the classic train/validation splits from i.i.d data to evaluate these methods.
Thus, several benchmarks have been presented to evaluate different shifts across various domains [9, 16].
For facial analysis, Sagawa et al.
[15] generate spurious correlations using annotated attributes in CelebA.
However, to the best of our knowledge, no structured benchmark currently exists to evaluate different types of naturally occurring shifts in the domain of facial analysis.
Consequently, our ﬁrst contribution is a framework to systematically create various subpopulationspeciﬁc shifts on facial data, depicted in Figure 1: underrepresented/missing subpopulations, spurious correlations, and group-speciﬁc label noise.
For this, we use FairFace [7], a balanced dataset in terms of age, race and gender, as a base dataset.
Furthermore, we want to address the following research question: What impact do these shifts have on the subpopulation-speciﬁc accuracy and to what extent do they affect the calibration?
To answer this question, we compare a baseline model with several known approaches for building well-calibrated models.
For reproducibility, we provide our code for creating the shifts and training. [Figure] r e q u e n c y L
[Figure]
l
[Figure] g e [Figure] [Figure]
[Figure]
[Figure]
[Figure]
F r e
[Figure]
u e n c y F r e q u e n c y
L
[Figure]
b e l
[Figure]
g e
[Figure]
[Figure]
Distribution shifts in facial data
In the following we describe the underlying data and modiﬁcations.
Baseline Data As a basis for our work we use the FairFace dataset [7] with 97,698 subjects and its standard train/test split. Additionally, we split off 12% of the training data as a validation set.
The dataset contains information on age, gender, and race, with special attention paid to the balance of these three attributes.
Following the notation of [7] the attribute gender is categorized into two classes ( A gender = { male , female } ), race into seven ( A race = { Black , East Asian , Indian , Latino Hispanic , Middle Eastern , Southeast Asian , White } ), and age into nine ( A age = { 0-2 , 3-9 , 10-19 , 20-29 , 30-39 , 40-49 , 50-59 , 60-69 , more than 70 } ).
2 We attempt to estimate the age categories y ∈ A label = { 0 , 1 , . . .
, 8 } by classiﬁcation, while A gender and A race are used to induce changes in the data distribution of the training data.
The test data remains the same.
We systematically apply the shifts to each attribute value so that each of them is affected once.
Our goal is to examine the effects of several types of shifts without the inﬂuence of the number of training samples.
Therefore, we ensure that although we reduce the number of subjects from certain groups, the total number of training samples per shift remains constant.
We achieve this through a general random sampling, also on the baseline data.
Subpopulation shift with one under-represented attribute value Subpopulation shifts can occur in the real-world when certain attribute values are underrepresented in the training data compared to the data seen during deployment, e.g. when a speciﬁc ethnic group is missing during training. Let v i ∈ A i be an attribute value for attributes i ∈ { race , gender } and let p clean ( v i ) be the probability of v i in our clean training data. To induce the subpopulation shift, we reduce the probability of this attribute value by a factor 0 ≤ q i ≤ 1 : p shift ( v i )
= q i · p clean ( v i ) . For the remaining attribute values w i ∈ A i \ v i we set the probability distribution to
[Equation] This is done for all v i ∈ A i and all shift intensities q race ∈ { 1 . 0 , 0 . 25 , 0 . 0 } and q gender ∈ { 1 . 0 , 0 .
Note that the selected attribute value does not occur at the strongest shift.
Label noise In addition to normal subpopulation shifts, there may also be biases in the labels for individual groups.
For example, certain races are estimated to be younger than they really are.
This can have isolated effects for these speciﬁc groups or for all others during the deployment.
To investigate this, we introduce attribute-speciﬁc label noise in the training data: for each race group separately, we reduce the age class by subtracting samples from an approximated half-normal distribution with mean 0 and increasing standard deviation σ ∈ { 0 . 5 , 1 . 0 , . . .
, 4 . 0 } from the ground truth labels.
Thus for a label y ∈
A label the new label is ˜ y = max(0 , (cid:100)
y − z (cid:101) ) , where z ∼ N [0 , ∞ ) (0 , σ 2 ) .
Spurious correlations Our last shift consists of spurious correlations between race and the label age .
We combine the lowest three age groups into the attribute value young , thus we create a new attribute set A generation = { young , not young } . We systematically correlate the attribute young with each race group in the training data.
Two variants for this correlation are considered: sufﬁciency (e.g. "young ⇒ East Asian" ) and equivalence (e.g. "young ⇔ East Asian" , depicted in Figure 1).
We create these variants by omitting subjects with certain race - age combinations: For example, for the spurious correlation "young ⇒ East Asian" we omit all young subjects that are not East Asian.
In the case of "young ⇔ East Asian" we additionally remove all non-young East Asians.
Thereby for each v race ∈ A race separately we ensure that p shift ( v race | v generation = young ) = 1 holds in the training data for the case sufﬁciency. For the case of equivalence we additionally have p shift ( v generation = young | v race ) = 1 .
For this shift we created a baseline with a reduced number of young subjects over all races to match the overall number of young subjects to isolate the effect of spurious correlations and exclude that of data set size (for young ).
Experimental setup
In our experiments we investigate the impact of the distribution shifts speciﬁed in section 2 on the classiﬁcation performance and calibration.
For this, we use a ResNet34 [6, 14] pretrained on ImageNet as a baseline model (denoted vanilla). For comparison, deep ensembles [10] of three independently trained networks are used, as they are generally considered a simple but effective way to improve the calibration [13]. Also the inﬂuence of mixup [18] is investigated, which can improve the calibration [17] and performs a data-level change compared to the ensembles.
Furthermore, we combine each of them with temperature scaling [5], a post-hoc recalibration method that divides the logit outputs by a scaling parameter before calculating the softmax.
We use a clean and balanced validation set for learning the scaling parameter.
Each of the three approaches offers comparably good performance in their respective categories. Therefore, in this paper we focus only on those. For each of these methods, we use the same training protocol. We train for 30 epochs using Adam [8] with weight decay of 0.01, learning rate of 0.0001 and apply a random crop of size 224.
RandAugment [2] is used for data augmentation. The weights of the epoch with the lowest validation loss are used for the evaluation. The basic hyperparameter setting was chosen based on [7] and then improved to replicate the results on the clean FairFace data. Since ensembles are independently trained networks, the same setting can be applied to them.
As mixup generally needs more epochs to converge, it was veriﬁed that the loss did not change signiﬁcantly after the speciﬁed epochs.
In addition to the classiﬁcation accuracy, we are particularly interested in the reliability of the conﬁdence outputs, which we measure with the ECE (Expected Calibration Error)
In the evaluation we include the results from 5 random seeds for all metrics and methods.
Results
In the following, we try to answer the research question for each of the deﬁned shifts.
First, we want to address the question of what impact the previously deﬁned changes in the distributions have on the accuracy.
We contrast the changes in the accuracy with the stability of the calibration.
This allows us to answer the question of whether our model remains at least reliable even when the accuracy deteriorates.
For this purpose, we focus on the relevant subpopulations that are affected by the changes. Thus, for a shift that affects attribute value v i we consider the accuracy and ECE over all subjects with this speciﬁc attribute value. We aggregate these results over all affected attribute values for each intensity level, such that the plots below show the spread over the results of the different relevant attribute values.
[Figure] Subpopulation shift For subpopulation shifts we considered both attributes: gender (see Figure 2a for the accuracy and 3a and 3b for the ECE ) and race (see Figure 5 in the Appendix).
We can observe that in both cases the accuracy of all methods deteriorates with increasing shift.
This effect is more pronounced for the attribute gender than for race when we compare the strongest shifts.
This poses the question of whether the existing race diversity in the dataset is sufﬁcient to learn race-invariant features, making the removal of a single race not very signiﬁcant.
The calibration error increases with a stronger shift.
Similarly, as for the accuracy this effect is larger for the shift in gender .
Among the compared approaches, ensembles and mixup result in an improvement of the calibration over vanilla; with mixup this effect is larger in the gender case.
A recalibration causes a slight stabilization of the baseline but leads to a deterioration of mixup.
Label noise In the case of group-speciﬁc label noise we see a clear drop of accuracy, by 7. percentage points (denoted %) with higher intensity (Figure 2b).
However, the calibration error seems to be relatively stable (max.
1.0% increase for vanilla, as can be seen in Figure 3c).
Interestingly, the calibration ﬁrst improves with slight noise.
An assumption would be that the otherwise overconﬁdent networks become more uncertain, which leads to an improved calibration.
We can observe that ensembles, as well as mixup, have better calibration without label noise, however, under label noise the vanilla network outperforms both of them.
On the other hand, ensembles have better accuracy under noise.
A recalibration (Figure 3d) reduces the gap between all methods and leads to stabilization over the noise intensities.
In this case, ensembles show the lowest ECE.
We also evaluated the subpopulations that did not encounter noise during training and observed that the accuracy worsens by only 1.5% for the vanilla network.
Therefore, we can conclude that the label noise applied to a single group does not exhibit a similarly strong performance degradation for all other groups.
Spurious correlations We investigate the effect of spurious correlations between young and each value of race .
We distinguish between the race groups that include the attribute young in the training data ( young-correlated ) and the remaining ones ( non-young-correlated ).
The accuracy increases for the young-correlated groups (by 14%) and decreases for the non-young-correlated groups (by 7.5%) with stronger spurious correlations (see Appendix A.2), while the spread between the different youngcorrelated observations increases.
In terms of calibration, we observe a signiﬁcant improvement for the young-correlated groups and a deterioration for non-young-correlated groups (see Figure 3e and 3f).
However, we notice that the models are poorly calibrated, thus the uncertainty estimates of the methods are not reliable.
As before, temperature scaling improves the calibration.
However, unlike for the other shifts, neither ensembles nor mixup can improve the calibration compared to vanilla and no clear ranking can be observed.
Conclusion & discussion
In this paper, we introduced several shifts for a given facial analysis dataset and investigated the impact on accuracy and calibration.
In summary, each type of distributional change has an increasingly negative impact on accuracy with higher shift intensity.
Also the calibration of the methods continues [Figure] to decline as the shift increases such that the models become less reliable.
Ensembles and mixup outperformed vanilla for the subpopulation shift, but for spurious correlations, there has not been a clear ranking and for label noise vanilla even performed better than the other methods.
For the case that a balanced validation dataset is available, a simple post-hoc recalibration can improve the ECE signiﬁcantly for all shifts.
It stabilizes the calibration for all methods and leads to an advantage of ensembles over the other methods.
However, getting a balanced data set poses difﬁculties in the wild.
We did not examine this effect concerning different modiﬁcations of the validation set, thus it remains unclear what signiﬁcance the speciﬁc composition of the validation set might play.
We leave this investigation for future work.
Acknowledgment
This work was supported by the Bavarian Ministry of Economic Affairs, Regional Development and Energy through the Center for Analytics Data Applications (ADA-Center) within the framework of “BAYERN DIGITAL II” (20-3410-2-9-8).
A Additional results A.1 Subpopulation shift
[Figure]
[Figure]
[Figure]
[Figure]