SelecMix: Debiased Learning by Mixing up Contradicting Pairs
Abstract
Neural networks trained with ERM (empirical risk minimization) sometimes learn unintended decision rules, in particular when their training data is biased, i.e., when training labels are correlated with undesirable features.
Techniques have been proposed to prevent a network from learning such features, using the heuristic that spurious correlations are “simple” and learned preferentially during training by SGD.
Recent methods resample or augment training data such that examples displaying spurious correlations (a.k.a. bias-aligned examples) become a minority, whereas the other, bias-conflicting examples become prevalent.
These approaches are difficult to train and scale to real-world data, e.g., because they rely on disentangled representations.
We propose an alternative based on mixup that augments the bias-conflicting training data with convex combinations of existing examples and their labels.
Our method, named SelecMix, applies mixup to selected pairs of examples, which show either (i) the same label but dissimilar biased features, or (ii) a different label but similar biased features.
To compare examples with respect to the biased features, we use an auxiliary model relying on the heuristic that biased features are learned preferentially during training by SGD.
On semi-synthetic benchmarks where this heuristic is valid, we obtain results superior to existing methods, in particular in the presence of label noise that makes the identification of bias-conflicting examples challenging. Correspondence to: Published at the ICML
1. Introduction
The inductive biases contributing to the success of deep neural networks (DNNs) can sometimes limit their capabilities for out-of-distribution (OOD) generalization.
DNNs are prone to learn preferentially simple, linear predictive correlations from their training data, sometimes ignoring more complex but important patterns (Shah et al., 2020).
It has been suggested that simple correlations in the data are often spurious (Dagaev et al., 2021).
Consequently, a DNN relying on these spurious correlations will display poor OOD generalization.
Spurious correlations in a dataset are often the result of a selection bias, and such datasets are therefore said to be biased .
Biased datasets typically contain a majority of so-called bias-aligned examples and a minority of bias-conflicting ones.
In bias-aligned examples, ground truth labels are correlated with both robust and biased features.
In biasconflicting examples, labels are correlated only with robust features.
Clearly, the issues of models trained on biased datasets stem from the prevalence of bias-aligned examples.
Various approaches for debiased learning have been proposed. They encourage models trained on biased datasets to ignore biased features.
However, the identification of biased features from i.i.d. data is ill-defined, and requires additional assumptions or supervision with heterogeneous (non-i.i.d.)
training examples (Sch ¨ olkopf et al., 2021).
In this work, we approach debiased learning with the popular heuristic that biased features are “easier to learn” than robust ones, meaning that they are incorporated in the model earlier during training by SGD (Shah et al., 2020).
The intuition is that spurious correlations often result from selection biases that induce linear relationships between biased features and the target variable. In comparison, the target task is assumed to be a more complex, non-linear function of the inputs (Dagaev et al., 2021).
In addition, DNNs were shown to preferentially learn linear predictive patterns (Shah et al., 2020).
See Zhang et al.
for a discussion of the disputed relevance of this heuristic to real-world data.
Existing works that use this heuristic typically train two separate models: (i) an auxiliary model that purposefully relies on biased features, and (ii) the desired debiased model.
The auxiliary model serves to guide the training of the debiased one.
Nam et al.
(2020) train the auxiliary model with the generalized cross-entropy (GCE) loss (Zhang & Sabuncu, 2018) that strengthens its reliance on biased, easyto-learn features.
The simultaneous/subsequent training of the debiased model either augments the data with novel bias-conflicting examples (Kim et al., 2021; Lee et al., 2021) or upweights/oversamples existing ones (Nam et al., 2020).
Augmentation can be more effective than upweighting/oversampling but it requires careful tuning and/or disentangled representations that makes the application to realworld data difficult.
We propose a simple and effective method based on the mixup (Zhang et al., 2018) that generates new biasconflicting examples.
Mixup is a general data augmentation that creates convex combinations of randomly-chosen pairs of examples and their labels.
A naive application of mixup to a biased dataset is likely to combine bias-aligned examples – the majority of the data – and therefore aggravate bias issues.
Instead, we propose SelecMix, an application of mixup to selected contradicting pairs of examples.
We define contradicting pairs as having either (i) the same ground truth label but dissimilar biased features, or (ii) different labels but similar biased features.
To compare examples with respect to their biased features, we use an auxiliary model.
We train this model to implicitly identify the biased features with the heuristic that they are “easier to learn” than robust ones.
We train this auxiliary model with a novel generalized supervised contrastive (GSC) loss which is the modification of supervised contrastive (SC) loss (Khosla et al., 2020). It serves to amplify the reliance on easy-to-learn features.
We evaluate our method on standard debiasing benchmarks.
SelecMix consistently outperforms prior methods, in particular in the presence of label noise.
Label noise is particularly challenging because it increases the difficulty of identifying bias-conflicting examples.
We demonstrate this capability on novel versions of standard benchmarks modified to include label noise.
2. Related work
Debiasing with known forms of bias or bias labels.
Early works on debiasing assume some knowledge about the bias.
Some methods require labels for the bias features with every training example (Hong & Yang, 2021; Tartaglione et al., 2021;
Kim et al., 2019; Sagawa et al., 2019; Li &
Vasconcelos, 2019).
Other methods use knowledge of the general form of the bias, such as color or texture in images.
This information is typically used to design custom architectures (Wang et al., 2018;
Bahng et al., 2020; Cadene et al., 2019).
For example, ReBias (Bahng et al., 2020) uses a
BagNet architecture (Brendel & Bethge, 2018) as an auxiliary model because it focuses mainly on texture, which is assumed to be the biased feature.
The auxiliary model then guides the training of a debiased model that is robust to unusual variations in texture.
Debiasing with the easy-to-learn heuristic.
A number of recent works assume that biased features are learned more quickly than robust ones (Lee et al., 2021;
Nam et al., 2020).
A popular approach is to train an auxiliary model that intentionally relies primarily on biased features, e.g., through a noise-robust loss function (Zhang & Sabuncu, 2018).
The auxiliary model then guides the training of a debiased model that focuses on other, presumably non-biased features.
For example, “Learning from Failure” (LfF) (Nam et al., 2020) learns biased and debiased models simultaneously.
Bias-conflicting training examples are then upweighted using the relative losses from the biased and debiased models.
Building on LfF, “Disentangled Feature Augmentation” (DFA) (Lee et al., 2021) argues for the importance of diversifying bias-conflicting examples.
The method uses data augmentation.
It assumes that biases and robust features can be disentangled and swaps them randomly to generate new bias-conflicting training examples.
The disentanglement required by augmentation methods (Kim et al., 2021;
Lee et al., 2021) is however a challenge with real-world data and it is often an ill-posed problem in itself (Locatello et al., 2019).
Our method also augments the data by mixing existing examples but it does not relies on disentangled representations.
3. Method
We first briefly describe the possible use of mixup as a debiasing strategy, assuming that the biased features are precisely identified and that each training example is provided with a bias label that indicates a precise value for its biased features.
Next, we move to a more realistic scenario where such labels are unavailable.
We then implicitly infer bias labels with an auxiliary model that compares examples with respect to biased features that are assumed to be “easier to learn” than robust ones.
3.1. Mixup for augmenting bias-conflicting examples
We call bias-aligned examples the data exhibiting spurious correlations between labels and some biased features.
We call bias-conflicting examples the remaining part of the data, which does not contain such spurious correlations.
Training a model on bias-conflicting examples alone would avoid the bias issues, but these only constitute a small fraction of the [Figure] training data in the problematic cases that we consider.
Our general idea is to use mixup (Zhang et al., 2018) to augment the pool of bias-conflicting examples.
Standard mixup is a popular augmentation technique known to improve various measures of robustness and generalization (Zhang et al., 2018; 2020).
It builds convex combinations of pairs of examples and their labels.
A generated example is given as:
[Equation]
where ( x 1 , y 1 ) and ( x 2 , y 2 ) are two original training examples (e.g. image and one-hot label vector) and λ is a random mixing coefficient, λ ∼ U [0 , 1] .
Our goal is to augment the fraction of bias-conflicting examples in the training data and thereby reduce the reliance of the model on biased features.
Assuming for now that bias labels are available, we can generate bias-conflicting examples by applying mixup on the pairs having either (i) the same ground truth label but different bias labels or (ii) different labels but the same bias label.
Any such pair includes at least one bias-conflicting example, such that mixup will generate additional ones as long as this original example is assigned a higher mixing weight in Eq.1.
3.2. Replacing bias labels with an auxiliary model
Bias labels are usually not available.
We now show how to train an auxiliary model to compare training examples with respect to their biased features, without explicitly identifying these features.
We make the assumption that biased features are easier to learn than robust ones, because they are involved in simpler (e.g., linear) predictive patterns.
Our auxiliary model is trained to rely primarily on biased features.
We train the auxiliary model with a contrastive objective (He et al., 2020;
Chen et al., 2020; Khosla et al., 2020) because it is known to induce a clustering in embedding space (better than standard cross-entropy) that reflects the similarity of training examples in terms of learned features.
These are biased features by our assumption, such that the clustering reflects the similarity of examples w.r.t.
their (unknown) bias labels.
We use the supervised contrastive (SC) loss of Khosla et al.
(2020): L SC = − (cid:80) i ∈B (1 / |P i | ) (cid:80) k ∈P i log p i,k where
[Equation]
[Equation]
exp ( z i · z j /τ ) ,
z i is the normalized embedding of image x i , B = { 1 , 2 , ..., B } is the set of indices in the current mini-batch, P i =
{ k ∈ B\{ i } | y i =
y k } is the set of positive examples relative to the example i (i.e., with the same label), and the scalar τ is a temperature hyperparameter.
As an experiment to confirm that the clustering of training examples in embedding space is based on biased features, we train the auxiliary model on all available (biased) data from the Corrupted CIFAR-10 dataset with the SC loss and compute the cosine similarity ( z i · z j ) of the embeddings of all pairs of examples.
Fig.
1 confirms that the data is clustered according to biased features early in the training.
In other words, predictive rules involving biased features are learned faster than those involving robust features, as desired.
Since the higher cosine similarity z i · z j implies a high probability p i,j , we interpret it as the likelihood of the pair ( i, j ) having similar biased features.
To further amplify the reliance of the auxiliary model on biased features, we define the generalized SC (GSC) loss as follows:
[Equation]
where ˆ p qi,k is a scalar having the same value as p qi,k , meaning that the gradient is not back-propagated through it.
The term ˆ p qi,k assigns higher weight to sample pairs with a high probability p i,k and thus amplifies the reliance on biased features.
We further compare the GCE and GSC losses in
Appendix A.2.
3.3. Training a debiased model
Equipped with our auxiliary model to quantifying the similarity of training examples in terms of biased features, we can now apply the mixup on pairs having either (i) the same label but dissimilar biased features ( contradicting positives ) or (ii) different labels but similar biased features ( contra- [Table] dicting negatives ).
Contradicting positives.
For each instance ( x i , y i ) in the current mini-batch (i.e., the “query”), we pick another one with the lowest cosine similarity (measured in the space of their embeddings produced by the auxiliary model) among the set of positive examples (i.e., with the same label as x i ):
[Equation]
where P i = { j ∈ B \ { i } | y i =
y j } , B = { 1 , 2 , ..., B } is the set of the sample indices in the current mini-batch, and g ϕ is the part of our auxiliary model producing embeddings, i.e., g ϕ ( x i ) =
z i .
Since we select the pair among the set of positives, the training loss of the mixed example is l ( (cid:101) x i , (cid:101) y i )
=
l ( λx i + (1 − λ ) x k , λy i + (1 − λ )
y k )
=
l ( λx i +(1 − λ ) x k , y k ) .
Since most of the examples are biasaligned in the training set, the query ( x i , y i ) is likely to be bias-aligned.
Since x i and the selected sample x k have the same label but dissimilar biased features, it is also likely that the biased features of x k are not correlated with the label.
Thus, to effectively generate an example that contradicts the prediction based on biased features, we sample λ ∼ U [0 , 1] and assign the smaller value among λ and 1 − λ to x i and the larger one to x k .
Contradicting negatives.
For each query x i , we select another one with the highest cosine similarity among negative examples (i.e., with a different label) as follows:
[Equation]
where N i = { j ∈ B | y i ̸
= y j } .
Similarly, we sample λ ∼ U [0 , 1] and let λ ← min( λ, 1 − λ ) .
In standard mixup, the training CE loss of the mixed sample is: l ( (cid:101) x i , (cid:101) y i ) =
l ( λx i + (1 − λ ) x k , λy i + (1 − λ )
y k )
= λ · l ( λx i + (1 − λ ) x k , y i )
+ (1 − λ ) · l ( λx i + (1 − λ ) x k , y k ) .
However, considering the fact that (i) the query ( x i , y i ) is likely to be bias-aligned, and (ii) the query x i and the selected sample x k share similar biased features, the first term λ · l ( λx i + (1 − λ ) x k , y i ) does not contradict the prediction based on biased features.
Thus, rather than interpolating the label, we assign (cid:101) y
i ← y k .
4. Experiments
In this section, we evaluate the proposed method on standard datasets used in the debiasing literature.
We also perform experiments on novel versions of these datasets that include label noise.
See Appendix A.1 for experimental details. Description of the datasets.
Colored MNIST is a modified version of MNIST (LeCun & Cortes, 2010).
It consists of colored images of ten digits where each digit is correlated with the color (e.g., most images of 1 are colored with red).
Target labels are the digit identity (i.e., 0 to 9).
The color is the biased feature. Corrupted CIFAR10 is constructed by applying different types of corruptions to images of different types of objects from CIFAR-10 (Krizhevsky & Hinton, 2009). For example, most images of dogs are corrupted with a Gaussian blur. Biased FFHQ (BFFHQ) (Lee et al., 2021) is constructed from the dataset of human faces FFHQ (Karras et al., 2019).
The target label in BFFHQ is the age, and the biased feature is the gender, which is a binary annotation in the original dataset.
The ratio of bias-conflicting samples in the training set is α ∈ { 0 .
5% , 1% , 2% , 5% } in { Colored MNIST, Corrupted CIFAR10 } and α = 0 .
5% in
BFFHQ.
For the Colored MNIST and Corrupted CIFAR10, the test set is unbiased, meaning that the biased features are not correlated to the label in the test set.
For the BFFHQ, the test set consists of bias-conflicting samples, following the previous work (Lee et al., 2021).
Low accuracy on the test set implies that the model relies on the simple biased features and fails to learn the robust features.
All datasets are available in the official repository of DFA (Lee et al., 2021).
[Figure]
Existing methods.
We compare our approach to the prior works Learning from failure (LfF) (Nam et al., 2020) and
Disentangled feature augmentation (DFA) (Lee et al., 2021).
Both also rely on the heuristic “easy-to-learn” property of biased features.
LfF trains an auxiliary model with a generalized cross-entropy (GCE) loss to amplify its reliance on biased features, then reweights examples for training a debiased model.
DFA disentangles biased and robust features with a similar principle as LfF, then augments the data for training a debiased model by swapping the biased features across examples.
We also include the Entangling and disentangling (EnD)
(Tartaglione et al., 2021), Rebias (Bahng et al., 2020) and HEX (Wang et al., 2018).
EnD leverages explicit bias labels.
Rebias and Hex are designed for a specific, known form of biased features such as texture in images.
Setup.
The backbone architecture used of all methods is a 3-layer MLP for the Colored MNIST, and a ResNet18 (He et al., 2016) for the Corrupted CIFAR10 and BFFHQ.
We set the batch size of 256 for { Colored MNIST, Corrupted
CIFAR-10 } and 64 for BFFHQ.
We train the models for 200 epochs for { Colored MNIST, BFFHQ } and 300 epochs for Corrupted CIFAR-10.
4.1. Main results
We apply our method to a vanilla ResNet18 (Baseline +
Ours) as well as on top of the LfF method (LfF + Ours).
We evaluate methods on the Colored MNIST, Corrupted CIFAR10, and BFFHQ.
As shown in Table 1, our method consistently outperforms existing ones, except ReBias on
Colored MNIST.
Their bias-capturing model BagNet (Brendel & Bethge, 2018)) is specifically tailored to color and texture as biased features by relying on local image patches as input.
Both DFA and our method augment the pool of bias-conflicting training examples, but DFA’s reliance on disentangled representations seems problematic on the more complex datasets.
Our method performs well on all datasets, owing to the simplicity of the mixup strategy.
Our method outperforms DFA by a large margin on BFFHQ while the gap is smaller on Colored MNIST where the disentanglement is easier.
4.2. Results under the presence of label noise
Label noise can negatively affect methods relying on the identification of bias-conflicting examples.
The reason is that training examples with noisy (i.e. incorrect) labels are difficult to distinguish from the bias-conflicting examples that we wish to upweight.
Fig.
2 shows that our method maintains better performance under label noise than competing ones.
We hypothesize that the robustness of our method comes from the nature of mixup, which is known to improve robustness (Zhang et al., 2020).
Note that we used the same hyperparameters for the label noise experiments and the main experiments.
5. Conclusions
We presented a method for debiased learning that augments the training data using mixup on selected pairs of examples.
The selection of these pairs is critical. It uses an auxiliary model that implicity identifies biases in the data by optimizing a loss designed to amplify reliance on biased features.
The whole approach relies on the heuristic that spurious correlations are “easy to learn” and that biased features are therefore incorporated earlier than others during training by SGD.
While this property is disputed (Zhang et al., 2022), our method outperforms existing approaches on semi-synthetic datasets designed to display this property.
Unlike existing methods, ours remains effective in the presence of label noise.
A. Appendix A.1. Experimental details
Implementation details.
To train the debiased model, we use the Adam optimizer with learning rates of 0.005, 0.001, and 0.0001 for the Colored MNIST, Corrupted CIFAR-10, and BFFHQ, respectively.
To train the auxiliary model, we use the
Adam optimizer with learning rates of 0.01 and 0.001 for the Colored MNIST and Corrupted CIFAR-10, respectively and standard SGD with a learning rates of 0.4 for BFFHQ.
All experiments were performed with a single NVIDIA RTX
GPU.
Regarding the hyperparameters of our method, we fixed the temperature of the contrastive loss at τ = 0 . 2 , and the hyperparameter of the GCE/GSC losses q = 0 .
7 for all datasets.
For the baselines, we follow the hyperparameters suggested by the original (Nam et al., 2020; Lee et al., 2021), even if they used different hyperparameter configurations for the different ratios in the same dataset.
Since there is no provision for an unbiased validation set in most existing benchmarks, we follow the evaluation protocol of prior works (Bahng et al., 2020;
Nam et al., 2020; Kim et al., 2021; Lee et al., 2021) and report the best test set accuracy (i.e., an “oracle” model selection).
Details of experiments with label noise (Sec. 4.2) We modified the Colored MNIST ( α = 1% ) and Corrupted CIFAR-
( α = 1% ) by replacing the label with a random one for a portion β ∈ { 0 .
5% , 1% , 2% , 5% } of the training examples.
A.2. Discussion on the relationship between the GCE and GSC losses
We discuss below the differences between the generalized cross-entropy (GCE) (Zhang & Sabuncu, 2018) and GSC losses.
To begin with, we first explain how GCE loss amplifies the reliance of the auxiliary model on biased features, compared to the standard cross-entropy (CE) loss.
It is defined as L GCE ( p , y ) =
(1 − p qy ) /q
where p is the softmaxed vector of predictions from the model and p y its y th component, y is the ground truth class ID, and q ∈ (0 , 1] a scalar hyperparameter.
The GCE simplifies to the CE loss as q → 0 .
Assuming that the predictions are produced by a model of parameters θ , the gradients of GCE and CE losses are related as follows:
∂∂θ L GCE θ ( p , y )
= p qy .
∂∂θ L CE θ
( p , y ) .
Here, the term p qy assigns the higher weight to the samples with a high probability p y , thus upweights the ”easy” samples and amplifies the reliance on biased features.
While the model trained with CE also focuses on biased features since they are learned first, the GCE was shown to be more effective in identifying bias-conflicting examples by Nam et al.
Similar to the GCE/CE, our GSC loss improves over the SC loss in encouraging the model to rely primarily on biased features.
The term ˆ p qi,k in Eq.
(2) plays the same role as the term p qy in the GCE.