Correct-N-Contrast: a Contrastive Approach for Improving Robustness to Spurious Correlations
Authors: Michael Zhang
Nimit Sharad Sohoni
Hongyang R. Zhang
Chelsea Finn
Christopher Re
Venue: ICLR 2022 Submitted (2022)
Keywords: spurious correlations
contrastive learning
robustness
group shifts

Abstract: Spurious correlations pose a fundamental challenge for building robust machine learning models. For example, models trained with empirical risk minimization (ERM) may depend on correlations between class labels and spurious features to classify data, even if these relations only hold for certain data groups. This can result in poor performance on other groups that do not exhibit such relations. When group information is available during training, Sagawa et al. (2019) have shown how to improve worst-group performance by optimizing the worst-group loss (GDRO). However, when group information is unavailable, improving worst-group performance is more challenging. For this latter setting, we propose Correct-N-Contrast (CNC), a contrastive learning method to train models more robust to spurious correlations. Our motivating observation is that worst-group performance is related to a representation alignment loss, which measures the distance in feature space between different groups within each class. We prove that the gap between worst-group and average loss for each class is upper bounded by the alignment loss for that class. Thus, CNC aims to improve representation alignment via contrastive learning. First, CNC uses an ERM model to infer the group information. Second, with a careful sampling scheme, CNC trains a contrastive model to encourage similar representations for groups in the same class. We show that CNC significantly improves worst-group accuracy over existing state-of-the-art methods on popular benchmarks, e.g., achieving $7.7\%$ absolute lift in worst-group accuracy on the CelebA data set, and performs almost as well as GDRO trained with group labels. CNC also learns better-aligned representations between different groups in each class, reducing the alignment loss substantially compared to prior methods.

Under review as a conference paper at ICLR 2022
CORRECT-N-CONTRAST. A CONTRASTIVE APPROACH FOR IMPROVING ROBUSTNESS TO SPURIOUS CORRE- LATIONS
Anonymous authors Paper under double-blind review
ABSTRACT
Spurious correlations pose fundamental challenge for building robust machine learning models. For example, models trained with empirical risk minimization (ERM) may depend on correlations between class labels and spurious features to classify data, even if these relations only hold for certain data groups. This can result in poor performance on other groups that do not exhibit such relations. When group information is available during training, Sagawa et al. (2019) have shown how to improve worst-group performance by optimizing the worst-group loss (GDRO). However, when group information is unavailable, improving worst-group performance is more challenging. For this latter setting, we propose Correct-N- Contrast (CNC), a contrastive learning method to train models more robust to spurious correlations. Our motivating observation is that worst-group performance is related to a representation alignment loss, which measures the distance in feature space between different groups within each class. We prove that the gap between worst-group and average loss for each class is upper bounded by the alignment loss for that class. Thus, CNC aims to improve representation alignment via contrastive learning. First, CNC uses an ERM model to infer the group information. Second, with careful sampling scheme, CNC trains contrastive model to encourage similar representations for groups in the same class. We show that CNC signifi- cantly improves worst-group accuracy over existing state-of-the-ar methods on popular benchmarks, e.g., achieving 7.7% absolute lift in worst-group accuracy on the CelebA data set, and performs almost as well as GDRO trained with group labels. CNC also learns better-aligned representations between different groups in each class, reducing the alignment loss substantially compared to prior methods.
INTRODUCTION
For many tasks, deep neural networks are negatively affected by spurious correlatioss-ddeeedeennce between observed features and class labels that only hold for certain groups of the data. For example, consider classifying images cows or camels, where 90% of cow images depict grassy backgrounds. model may learn to predict the "cow" class based on the background, and incorrectly classify cow images with non-grass backgrounds as camels (Ribeiro et al., 2016; Beery et al., 2018; Kaufman et al., 2012). This illustrates widespread issue where neural networks can achieve low test error on certain groups, yet high error on others (Blodgett et al., 2016; Buolamwini & Gebru, 2018; Hashimoto et al., 2018; Sagawa al., 2019). Prior works have shown that this problem is increasingly aggravated as the correlations between class labels and spurious features become stronger (Sagawa et al., 2020) and easier to learn (Arpit et al., 2017; Hermann & Lampinen, 2020). Since spurious correlations arise in many settings, we wish to design robust methods that perform well on all groups.
How can we obtain neural networks robust to spurious correlations? If group-defining information (i.e. spurious attributes) is known, common solution is to minimize the worst-group loss, e.g., with group DRO (GDRO) (Sagawa et al., 2019). However, such information may be expensive to collect, and we may not know the spurious attributes priori in a given data set Makken--Rayne et al., 2020). When group information is unavailable, prior works typically take a two-stage approach. They first train an ERM model, and then use this model to infer groups and train more robust model. For example, Sohoni et al. (2020) find that ERM models still learn group-specific features when trained to predict class labels. After first training an ERM model, they infer groups by clustering the ERM

---

Under review as a conference paper at ICLR 2022
Waterbird Water BG
Waterbird, Land
Lendhidd Water BC
2
Correct-N-Contrast
representation siggiment
Improve robustness
Input
GradCAM
Sample Contrastive
1
Witerbird
Wirebbidd
Landhind
Batches
"Waterbird"
"Landbird"
"Waterbird"
"Waterbird"
"Landbird"
"Waterbird"
Posibive
Negative
(b)
(c)
Figure 1: (a) ERM misclassifies samples by spurious background features, visualized with GradCAM (Selvaraju et al., 2017). (b) CNC uses contrastive learning to learn similar representations for same-class samples with different ERM predictions. (c) Resulting models ignore spurious attributes and classify samples correctly.
model's representations, and train new model with GDRO using these inferred groups. Creager et al. (2021) identify groups under which an initial trained ERM model would maximally violate the invariant risk minimization (IRM) objective (Arjovsky et al., 2019). With these groups they train a new model with GDRO or IRM. Nam et al. (2020); Liu et al. (2021) observe that ERM models often misclassify data points in minority groups, and thus train another model with re- weighted or upsampled points misclassified by an initial ERM model. While these methods promisingly leverage ERM learned biases to significantly improve worst-group error without training group labels, there still a gap between their robust performance and methods' such as GDRO that use group labels.
In this work, we ask how else we can improve model robustness using trained ERM model, and aim to close this gap by focusing on improving the learned representations of the robust model in the second stage. We support this direction with two key motivations. First, we find that higher worst-group performance consistently correlates with hidden-layer representations exhibiting higher dependence on class labels than spurious attributes. We quantify this correlation using geometric representation alignment (Wang & Isola, 2020), which measures the closeness of samples with the same class but different spurious attributes in the model feature space, and mutual information. This relation consistently holds across various data sets, and explains when prior upweighting methods improve worst-gras group error over ERM (Fig. 4). Second, we theoretically show that a model's representation alignment for given class can be used to upper bound the gap between its worst group and average loss for that class. Thus, we can improve representation alignment for a class, we can reduce the gap between worst-group and average loss for that class.
We thus propose Correct-N-Contras (CNC), a two-stage procedure using contrastive learning to encourage better representation alignment within each class. In the first stage. we train regularized ERM model similar to prior work (Liu et al., 2021; Creager et al., 2021), under the premise that ERM predictions help infer group information (i.e., spurious attributes). In the second stage, we wish to improve representation aligmment by "pulling together" same-class datapoints and "pushing apart" different-class datapoints, regardless of their individual groups or spurious features. To do so via supervised contrastive learning, we use the heuristic that samples with the same ERM predictions exhibit similar spurious features (and vice versa). With a randomly sampled anchor, we select samples with the same class but different ERM predictions as "positives" together, and samples from different classes but the same ERM prediction as hard "negatives" we want to push apart. Training second model with this sampling scheme and supervised contrastive learning encourages this model to ignore spurious correlations that the initial ERM model learned, and improves representation alignment between same-class data points. Thus, CNC corrects for the ERM model's mistakes with contrastive learning in the second model.
want to pull
We evaluate CNC on four popular and diverse spurious correlation benchmarks. Among methods that similarly do not assume training group labels, CNC substantially improves worst-group accuracy, obtaining up 7.7% absolute lift (from 81.1% % 88.8% on CelebA) over the prior state-of-the-ar JTT (Liu et al., 1021), and averaging 3.4% % lift across the four tasks. We also find that CNC nearly closes the gap labels, only falling short of GDRO's worst-group accuracy by 0.8% absolute. Finally, we validate that CNC indeed reduces the alignment loss compared to prior methods. This corresponds to an up to 71.19 % smaller gap between worst-group versus average accuracy for data points in the same class.
worst-group accuracy with robust training methods that assume training group
Contributions, We summarize our contributions as follows:
2

---

Under review as a conference paper at ICLR 2022
1. We empirically show that model's worst-group performance correlates with the model's align- ment loss between different groups within a class, and analyze this connection theoretically.
2. We propose CNC, two-stage contrastive approach to improve representation alignment and thereby learn representations robust spurious correlations.
3. We validate that CNC significantly improves worst-grout accuracy over existing methods on various benchmarks, and learns better-aligned representations less reliant on spurious features.
PRELIMINARIES
Problem setup. We present our setting and the loss objectives following Sagawa et al. (2019). Let X {........ .,. [nj and Y {y/...... yn be training data set of size n. Each data point has an observed feature vector E N. label yi E V, and unobserved spurious attribute E A. The set of groups G is defined as the set of all combinations of class label and spurious attribute pairs, i.c. G - ) x A. Let C = | be the number of classes and K [ be the number of groups. Following the classical supervised learning setting, we assume that each example (I; Vr, a;) drawn from an unknown joint distribution P. We assume that at least one sample from each group is observed in the training data. Let Pg be the distribution conditioning on (y, a) = 9, for any g E G.
Given a model fo X > TRC and a convex loss l. x y + R. let the worst-group loss be: E (.s.,.)) [ [((ff())
Cfg(fo) = max gEg
(1)
ERM minimizes the training loss as a surrogate for the expected population loss Lavg:
Lave (fo) = p(axx.a)=p((((((())) y)l
(2)
While ERM is the standard way to train neural nets, spurious correlations often cause ERM to obtain high error on minority groups even when average error is low. Group DRO, which minimizes the empirical version of (1), is recognized as a strong baseline for improving worst-group error when the group labels (a1...... an are available during training (Sagawa al., 2019). In contrast, we focus on the more challenging setting in which the group labels are not available during training.
Contrastive learning. We briefly describe contrastive learning (Chen et al., 2020), a central com- ponent of our approach. Let fo be neural network model with parameters 0. Let the encoder fene + RRd be the feature representation layers of fe. Let fes Rd + nº be the classification layer of fe. which maps encoder representations to one-hot label vectors. We learn fene with the supervised contrastive loss Coup proposed Khosla et al. (2020). For each anchor I, we sam- ple M positives {2 M Ti=1 and N negatives {2, { Let y, fy." Ji=1: {y, J be the labels and 2, ( Ii=1, {2, }/ be the normalized outputs of fenc(x) for the anchor, positives, and negatives respectively. With input x mapped to 2, the training objective for the encoder to minimize:
exp(z T ///TT)
Coup (Ir; fenc)
E 1 1
log
(3)
JM
MM Σ
exp(z
() Ed exp(x žn /
where 7 >> 0 is a scalar temperature hyperparameter. Minimizing Eq. leads to z being closer to = than =- in feature space. See Sec. 6 for further references related contrastive learning.
3 MOTIVATIONS FOR REPRESENTATION ALIGNMENT
To motivate our method, we present our core observation that model's worst-group accuracy correlates with how well its learned representations depends on the class labels, but not the spurious attributes. First, we empirically observe that ERM learns spurious correlations by inspecting their hidden layer representations on several spuriously correlated data sets. We find that ERM's worst- group performance is inversely related to cross cross-group alignment loss (cf. Eq. (4) below) and mutual information metrics. Second, we theoretically prove that this alignment loss serves as an upper bound on the gap between the average-group loss and the worst-group loss (cf. Theorem 3.1).
3

---

Under review as a conference paper at ICLR 2022
3.1 RELATING WORST-GROUP PERFORMANCE TO REPRESENTATION ALIGNMENT
We first show that when neural networks are trained with standard ERM on spuriously correlated data, their hidden layer representations exhibit high dependence on the spurious attribute. We quantify this behavior using representation alignment (cf. Eq. (4) below) and mutual information metrics. We observe that these metries explain trends in ERM's is worst-group accuracy on various spuriously correlated data sets. This relationship is also consistent and applies to upsampling methods (JTT) that mitigate the impact of spurious features (Liu et al., 2021).
5-class, Peoer 0.95,
Train
We model spurious correlations with CMNIST", colored MNIST data inspired by Arjovsky al. (2019). There are 5 digit classes and 5 colors. We color a fraction Poor of the training samples with a color a associated with each class y, and color the test samples representations, we train a LeNet-5 CNN (LeCun et al., 1989) with ERM to predict digit classes, and inspect the outputs of the last hidden layer 2 = (x)) As shown in Fig. 2, with low Poors models learn representations with high dependence the actual digit classes. However, with high Poom we learn 2 highly dependent on a, despite only training to predict y.
2
S
6
6
f 9
3
+4
72
9
B
To analyze learned
0.95
Figure 2: UMAP visualization of
learned CMNIST" representations.
Representation metrics. To quantify this behavior, well the learned representations exhibit dependence on the class label vs. the spurious attributes. First, we compute an alignment loss [alien(fenci 9, g') between two groups where a F a'. This measures how well fene maps samples with the same class, but different spurious attributes, to nearby vectors via Euclidean distance. Letting G and G' be the subsets of training data in groups y and g' respectively, and x and x' be any two samples in G and G', we define:
two metrics designed to capture how
(y, a) and g' (y, a')
Caliga (fenci 9.9 g.g)==
(lfene(x) (=))(=")1l2 (a.y,))EG (x' (..""'")
Σ
E
(4)
G G"
Thus, lower Latign means better alignment. We also quantify representation dependence by estimating the mutual information (MI) of a model's s learned representations with the class label, i.e. ī(Y: Z) and the spurious attributes [(A; Z). We defer computational details to Appendix E.
CMNIST' Acc. (ERM)
Alignment Loss vs Acc.
Representation MI Ace.
Mutual Info (ERM)
Worss group Acc.
Worst- group Acc.
Represestation MI
0
kry 20
830
3.2
4.6
54
00
32
Piom
AA: (c)
Poor (d)
(a)
(b)
Figure 3: Accuracy and representation metrics from ERM models trained increasingly spuriously correlated
Colored MNIST. High worst- gorst accuracy corresponds to both ī(Y; 2) > [(A; Z) and small alignment loss.
Results for ERM. In Fig. 3 we show a strong association between worst-group error and both alignment and mutual information met- rics. As Poon increases, ERM models not only drop in worst-group accuracy, but also incur higher alignment loss (Fig. 3ab). Fig. 3c fur- ther illustrates this with mutual information. We plot the estimated mutual information and worst-group accuracy for models each epoch. A substantial drop in worst-group ac- curacy occurs with high (A; Z) (especially when i(A; 2) > I(Y; Z), even with high i(Y; Z)). Fig. 3d also captures this trend with a trade off between high i(Y; Z) with i(A; Z) as Peor increases (Fig. 3a).
CMNIST" Acc. (TT))
Mutual Info (TT)
Ho lepresentation ML
4.25
fry:
3u
1.00
NA 2)
Wasst-group
95
0.75
0,50
00
0.8
0.8
1.0
0.2
11.4
0.6
025
1.0
Pooor
(b)
Figure 4: Higher worst-group accuracy with upsampling coincides with keeping i(y; 2) > i(A; Z).
4

---

Under review as a conference paper at ICLR 2022
Results for JTT. In Fig. 4, we also show that this relation holds when training with another recent (upsampling) approach, JTT (Liu et al., 2021). With high Peor: models now achieve higher worst- group accuracy, and this corresponds to learning representations with high class label and low spurious attribute dependence. We note however that previous approaches do not explicitly optimize for these representation metrics, suggesting new direction to improve worst-group performance.
3.2 RELATING ALIGNMENT LOSS TO WORST-GROUP LOSS
The empirical observations in Fig. 3 suggest that lower alignment loss correlates with lower worst- group error. Next, we show that this connection applies much more generally. We show that the maximum of Catign 9: g'). over any two groups 9: g within the same class, can be used to upper bound the gap between the worst-group loss and average loss for that class. We set up several notations before stating the result. For any class label y E y, let Gy be the set of groups with label in G. Let Lwg(Jon y) be the worst-group loss among groups in Gy:
Lug(Joi := max I [e(fax)). gegy (2.8.a)~PP
Let Lavy (Jo be the average loss among groups in Gy: Lave(So; ==
E (2...a))
( ()]o(r),ū)]
Additionally, we define a class-specific alignment loss Laiign (fne: y) among groups in Gy, Recall that fe involves an encoding function fene and a linear classification layer fels. We define (fnns y) as the largest goosp alignment loss among groups in Gy:
Caliga (fo:
max gegy.9 EG, grt'
Latign (fenc 9, 9.9").
(5)
where Latign (Jenei 9s g.g") ) is the alignment loss between g and g' defined Eq. (4). Our main result is that Latiga( (fe: y) is an upper bound on the gap between Lug (fo y) and Cavg(fe; (fe; )) (up to a norm multiplier and a concentration error), for any y E y.
Theorem 3.1 (Aligmment loss upper bounds the gap between worst-group and average- group loss). In the setting described above, let fo be any neural network satisfyyng that the weight matrix of the linear classification layer W in sels satisfies that [[[] I B, for some constant B. Let ng be the size of any group g E G in the training data set. Assume that the loss function f(x, y) C1-Lipschitz and bounded from above by C2. for some positive constants C1: C2. Then, with probability at least
1 over the randomness of the training data set samples, for any class y E V, the following holds:
(log(1)u1/8)
Ewe(foiu) S (Sow)) + C1 Latign y) mmax C2 gEs,
(6)
Thg
The proof of Theorem 3.1 is deferred to Sec. B. Since also know that Lavg (fo; v) S Low (Foz v). the above result implies that in order to reduce the gap between the worst-group loss and the average loss for class y, it suffices to reduce the alignment loss Latggn v).
Broader algorithmic implications. We summarize Section with two takeaways: (1) When trained on spuriously correlated data sets, ERM networks learn data representations highly dependent on spurious attributes. Clusters of these representations (Sohoni al., 2020) or the ERM model's outputs (Liu et al., 2021; 1; Nam et al., 2020) can thus serve as (noisy) pseudolabels for spurious attributes. (2) Both representation metrics correlate with worst-group error, such that a viable way to improve worst-group performance is to improve representation alignment within each class.
CORRECT-N-CONTRAN
(CNC)
We now present CNC, two-stage method to improve worst-group performance and robustness to spurious correlations, without requiring training group labels. Similar to prior works (Sohoni et al., 2020: Liu al., 2021), our first stage trains an ERM model (with proper regularization') on the training set, ultimately to infer group labels based on samples' spurious attributes.
As we train on the same data set we infer the groups on, regularization (via high weight decay or early stopping) is purely to prevent the ERM model from memorizing the class labels. This is standard practice also discussed in Sohoni et al. (2020); Liu et al. (2021). We show in Sec. 5.3 that we do not require the ERM model perfectly learn the spurious attributes for CNC to substantially improve robustness in practice.
5

---

Under review as a conference paper at ICLR 2022
Algorithm 1 Conrect---Contrst (CNC)
Input: Training data set (X, Y); # positives M; # negatives N; learning rate n, # epochs K.
Stage 1: ERM Training
1: Train a regularized ERM model fa on (X, )): save the predictions d: == fg(())).
Stage 2: Supervised contrastive learning
2: for each epoch :..... K do
3: for each anchor (x, y) E (X,Y) (,,Y)do do
4: Let ğ the predicted (group) label æ from Stage I's ERM model.
5: Get M positives {< vih) where yi but Dth F y. for m = ,,..,,M. M.
6: Get N negatives {(2g No }} where U4 # y but Ugg
for q = I....,N.
7: Update fo by +- - 7. (i. y) (ef. Eq. (7)) with anchor, M positives, and negatives. return final model fe from Stage 2, and throw away the ERM model from Stage 1.
The key difference is our second stage: we aim to train more robust model by learning representations such that samples in the same class but different groups are close to each other. We use contrastive learning, as intuitively by treating samples with the same class but different spurious attributes as distinct "views" of the same class, we train the second stage model to "pull together" these samples' representations and ignore the different spurious features. This is also inspired by Wang & Isola (2020); Robinson et al. (2021), who show that minimizing the contrastive loss improves representation alignment between distinct "views". Later in Sec. 5.1, we verify that CNC indeed reduces Latian y) substantially. We include further details on both stages below, and summarize CNC in Algorithm 1.
Stage 1: ERM training. We train initial model fa on the training data set {1r,, ys y:) with ERM and regularization, and save its predictions (ū: } on the training data points. We consider Two ways source predictions: using the ERM model's s outputs, and clustering its last hidden-layer representations. Both approaches aim to accomplish the same goal of exploiting the ERM model's learned spurious correlations; further details are in Appendix E.2.
Stage 2: Contrastive learning (CL). Next, we train a robust model with supervised contrastive learning using the ERM predictions. While CNC inspired by recent CL works (Chen et al., 2020; Khosla et al., 2020), we introduce new "contrastive batch" sampling and optimization objectives.
Contrastive batch sampling. As described in Sec, 2, contrastive learning requires sampling anchors, positives, and negatives with the general form {z), { J, {x-). J. Here, we wish to sample points such that by maximizing the similarity between anchors and positives (and keeping anchors and negatives apart), the Stage 2 model "ignores" spurious similarities while learning class-consistent dependencies. With prediction set {ūe 1ー=1, for each batch we randomly sample an anchor 2; E X (with label y: and ERM prediction út), M positives with the same class as ys but different ERM model prediction than ÿs, and N negatives with different classes as y/ but the same ERM model prediction as ÿi. For more signal per batch, we double pairwise comparisons by switching anchor and positive roles.
Optimization objective and updating procedure. While our core objective is to learn aligned repre- sentations via contrastive learning, we also wish to train the full model to classify datapoints correctly. As we have the training class labels, we jointly update both the model's 's encoder layers fene with standard contrastive loss, and the full model fo with a cross-entropy loss:
x. ( 8) + (1 A) (fo: x. V).
In the above, LeuR (Jenci v, y) is the supervised contrastive loss of x along with its positive and negative samples, similar to Eq. (3) (see Eq. (16) in Sec. C.2 for the full equation); Lanosa (fo; xr y) is averaged cross-entropy loss over 2, the M positives, and the N negatives; À E [0. 1] is a balaneing hyperparameter. As a remark, the loss objective (7) uses a single anchor in each batch in our setting.
M To calculate the loss, first forward propagate one batch (I:: (x } m= (x J.Y
1 through fenc and normalize them to obtain representation vectors (2,, {2it 1 Im {2 N 1). To learn closely
aligned 24 and =+ for all {=/t 1M we update fene with the (x; fene) loss. Finally, we also pass the unnormalized outputs of the encoder fene to the classifier layers fea. and compute a batch-wise cross- cross-entropy loss (fr using each batch sample's pe class labels and fo outputs. Due to space constraints, we include further implementation details and sampling considerations in Appendix C.
6

---

Under review as a conference paper at ICLR 2022
5 EXPERIMENTAL RESULTS
We conduct experiments to answer the following questions: (1) Does CNC improve worst-group performance over prior state-of-the-ard methods on data sets with spurious correlations? (2) Does CNC actually encourage learning hidden layer representations with greater alignment and class-label- only dependence? How is this impacted by the strength of spurious correlation in the data? (3) Does CNC require perfectly predicting the spurious attribute to work well in practice? Our results for each question follows in the next three subsections (5.1, 5.2, and 5.3). Due to space constraints, we defer ablations on CNC's design choices, including the representation-lese leamning objective and sampling procedure, to Appendix A. Additional comparison to alignment methods proposed for domain adaptation but adjusted for our setting are in Appendix A.2. Below, we briefly describe the benchmark data used in this section. We run CMNIST with Peor 0.995. Further details data sets, models, and experimental hyperparameters are deferred to Appendix E.
Waterbirds (Sagawa et al., 2019): We classify y (waterbird, landbird), where 95% of images have the same bird type and background A = |water background, land background).
CelebA (Liu al., 2015): We classify celebrities' hair color {blond, not blond} with A = {male, female]. Only 6% of blond celebrities in the data set are male.
CivilComments- WILDS (Borkan al., 2019; Koh al., 2021): We classify y ttoxic, not toxic] comments, AA denotes whether the comment mentions one of eight demographic identities.
5.1 CNC IMPROVES WORST-GROUP PERFORMANCE
To study (1), we evaluate CNC on image classification and NLP data sets with spurious correlations. As baselines, we compare against standard ERM and an oracle GDRO approach that assumes access the group labels. We also compare against recent methods that tackle spurious correlations without requiring group labels: CVaR DRO (Levy et al., 2020), GEORGE (Sohoni et al., 2020), Learning from Failure (LfF) (Nam et al., 2020), Predictive Group Invariance (PGI) (Ahmed et al., 2021). Environment Inference for Invariant Learning (EIIL) (Creager et al., 2021). Contrastive Input Morphing (CIM) (Taghanaki et al., 2021), and Just Train Twice (JTT) (Liu et al., 2021). We also compare against a CNC version without the Stage ERM model, instead only sampling positives and negatives based on class (denoting this SupCon*). Results are reported in Table 1. CNC achieves highest worst- group accuracy among all methods without training group labels the CMNIST Waterbirds and CelebA data sets, while also obtaining near-SoTA worst-group accuracy on CivilComments.
While LIF, GEORGE, PGI, EIIL, and JTT similarly use trained ERM model to estimate groups, CNC uniquely uses ERM predictions to encourage the robust model to learn desirable representations via contrastive learning. We reason that with this approach, by sampling positives and negatives from the ERM predictions, CNC more directly encourages the robust model to ignore learnable spurious correlations compared to previous invariant learning, input transformation, or upweighting approaches. We include additional evidence of this via GradCAM visualizations in Appendix G.
Alignment Loss
Ground-trtth Label MI
Le
Spurious Attribute
Landbirds Waterbirds
Accuracy (%)
80
Cuffon
12 2001
i(A: 2)
70
BRM JTT
DRM
ERM
60
JIT
JTT
CNC (Curs)
CNC (Dand)
CNC (Curs)
30
60
Waterbirds
Celeba
Watterhiris
CelehA
Waterbirds
CelobA
WG
Avg
(a)
(b)
(c)
(d)
Figure 5: Alignment loss (a) and mutual information (b, c) of models trained with ERM, JTT, and CNC, on Waterbirds and CelebA. CNC most effectively removes dependence on the spurious attribute, and obtains smaller gaps for per-class worst-group vs. average eиror (d), supported by Thm. 3.1.
5.2 CNC LEARNS REPRESENTATIONN LESS RELIANT ON SPURIOUS FEATURES
To shed light CNC's worst-group accuracy gains, we investigate if models trained with CNC actually learn representations with higher alignment. Compared to ERM and JTT (the next-best per- forming method that does not require subgroup labels), CNC leams representations with significantly higher alignment (lower alignment loss) and lower mutual information with spurious attributes (while having comparable mutual information with class labels) (Fig. 5 and Fig. 7).
7

---

Under review as a conference paper at ICLR 2022
Table I: Worst-group and average accuracies, averaged over three seeds (standard deviations in parenthesis). On image data sets, CNC obtains significantly higher worst-group group accuracy than comparable methods without group labels, competing with GDRO, CNC also competes with So on CivilComments. Results without standard deviations are reported from the original papers. Further implementation details are in Appendix E.
Method
CMNIST
Waterbirds
CelebA
CivilComments WILDS
Accuracy (%) Worst-group
Avg.
Worst-group
Avg.
Worst-group
Avg.
Worst Worst-group
Avg.
ERM
(.0)
20.1 (0.2)
72.6
97.3
47.2
95.6
57.4
92.6
CVRR DRO
61.3 (4.1) (5.0)
75.9
96.0
64.4
82,5
60.5
92.5
LfF
0.0
25.0 (0.5)
78.0
91.2
77.2
85.1
58.8
92.5
GEORGE
(2.3)
89.5 (0.3)
83.8 (1.0)
95.7 (0.5)
(1.9)
94.6 (0.2)
PGI
88.5 (1.8)
73.8 (0.8)
(0.1)
77.8 (1.8)
82.0 (0.6)
CIM
(.0))
77.2
95.6
83.6
90.6
N/A
N/A
EIIL
72.8
90.7 (0.9)
78.7
96.9
(0.8)
85.7 (0.1)
67.0 (2.4)
90.5 (0.2) 91.1
JTT
74.5
(0.8)
86.7
93.3
81.1
88.0
69.3
SupCon
(0.0)
(1.9) (1.2)
85.9 (0.8)
(1.1)
90.0 (0.1)
CNC (Ours)
77.4 (3.0)
90.9 (0.6)
89.7 (0.2)
90.8 (0.1)
88.8 (0.9)
89.9 (0.5)
68.9 (2.1)
81.7 (0.5)
Group DRO
78.5 (4.5) 90.6 (0.1) 91.1 (0.2) 92.4 (0.2) 88.9 (1.3) 93.9 (0.1) 69.8 (2.4)
89.0 (0.3)
ERM
JTT
CNC
Landbie
Rackground
Landhird Wisterbird
Land Background
Landbird
Land Background
Weterbird
Water Beckground
Weter Beckgrourd
Waterbbrd
Weter Background
Figure 6: UMAPs of Waterbirds representations. colored by class (left) and spurious attribute (right). ERM depends on both classes y and spurious attributes A, though with greater separability for the latter. JTT representations depend more on }/, but also on A. CNC gets closer to fully removing the dependence on A.
We find that CNC representations exhibit the lowest alignment loss consistently for these data sets; this also corresponds to CNC models achieving the highest worst-group accuracy. Furthermore, while all methods result in representations that exhibit high mutual information with the class label (Fig. 5b), only CNC results in representations that drastically reduce mutual information with spurious attributes (Fig. 5c). In Fig. 6, we also illustrate this result on the Waterbirds data set via UMAP visualizations of the learned representations. Notably, all training methods result in representations separable by class label. Yet ERM models exhibit strong separability by spurious attributes, and JTT models interestingly also still depict some learned dependency the spurious attribute. However, CNC uniquely learns representations that strongly depict lasss-label-olly dependence.
In addition, to study how this relation between representation metrics and worst-group accuracy scales with the strength of the spurious correlation, we compute representation metrics with CNC, ERM, and JTT models trained on increasingly spurious (1 Powor) CMNIST data sets in Fig. 7. We observe that with high spurious correlations, ERM fails to classify digits in the minority classes, while CNC and JTT comparably maintain high worst-group accuracy. CNC also performs better in more spurious settings (Peor > 0.95). These improvements over ERM are reflected by drops in alignment loss (averaged over classes); CNC consistently achieves lowest such loss. Fig. 7c shows that CNC's s learned representations maintain a more favorable balance of mutual information between the class label and spurious attribute than JTT. While JIT models exhibit slightly higher estimated T(Y; Z) than CNC models, CNC models exhibit much lower dependence on the spurious attribute.
5.3 UNDERSTANDING CNC's s SENSITIVITY TO STAGE PREDICTIONS
Finally, study how sensitive CNC is to how closely the Stage ERM model actually predicts the spurious attribute. As JTT also relies on an initial ERM model's predictions, we compare CNC to JTT in this regard. We find that CNC is more robust to noisy ERM predictions than JTT, and that CNC does not require perfectly inferred groups to perform well.
We first conduct ablation on CNC and JIT's group and average performance in Fig. 7d with the following synthetic experiment. On CMNIST*, we start with the true spurious attribute labels as the Stage 1 "predictions". We then gradually degrade their quality as follows: for each point, with
8

---

Under review as a conference paper at ICLR 2022
Worst-group Anc. %
CMNIST Worst-group Acc.
CMNIST Aligument Loss Est. Mutual Info. vs Spuriouspess
Stage Prediction Ablation
100
Representation MI
90
80
80
Colgg
%
0.
Acc.
20
40
0.4
60
0.3
0.0
Pcom
9.8
0.55
0.50
0.400
Poom
0.50
0,000
0.00
0.00
0.30
0.15
0.20
0.25
ERM
JTT
CNC (Ours)
Kt, X), CNC
its. 20,
CNG Ang
JTT JIT Aug
(b)
(c)
Figure 7: Alignment loss and mutual information representation metries with worst-group accuracy on increasingly spurious CMNIST". CNC highest worst-group accuracy (a) coincides with leamning representations
with better alignment (b) and ratio of mutual information dependence on the lahels vs the spurious attribute (c). probability p we change its assigned spurious attribute label to a different label chosen uniformly at random. Both methods' performance degrades as p increases and the Stage "predictions" degrade. However, CNC consistently achieves higher worst-group accuracy and smaller worst-group versus average accuracy gaps. We also observe on other data sets that CNC does not require perfectly spurious ERM predictions to work well. For the Waterbirds and CelebA results in Table 1, the Stage 1 ERM model predictions align with the spurious attribute value 94. 94.7% and 59.3% of the time respectively. While the ERM model is far from perfect at recognizing the spurious attributes, CNC still substantially reduces the porst-group vs. average accuracy gap.
6 RELATED WORK
We build on prior work in group robustness and contrastive learning. Further discussion is in App. D. Robustness to group shift. A variety of approaches aim to improve performance on minority data groups If group labels are known, many works minimize a rebalanced error similar in motivation to correcting class imbalance (He & Garcia, 2009; Cui et al., 2019) or importance weighting (Shimodaira, 2000; Byrd& & Lipton, 2019). More recently. Sagawa et al. (2019) minimize worst- -roup loss during training. Goel al. (2020) achieve further lift by synthetically generating additional minority group points. Cao et al. (2019) regularize updates on minority groups to improve their generalization.
Another line of work aims improve group robustness without assuming group labels for the training data. The most similar methods to CNC first train an initial ERM model with class labels as a way to infer groups, and then use these groups to train second model with better worst-group performance. GEORGE (Sohoni et al., 2020) clusters ERM representations. and runs GDRO with these clusters as inferred groups. EIIL (Creager al., 2021) and PGI (Ahmed et al., 2021) infer groups that maximally violate an invariance objective for the ERM model. With these groups EIIL uses either GDRO or Invariant Risk Minimization (Arjovsky et al.. 2019) to train second robust model, while PGI minimizes the KI. divergence of the softmaxed logits for samples in the same class but different groups. LfF (Nam et al., 2020) use a generalized cross-entropy loss to encourage misclassifying minority groups, concurrently training second model with these datapoints upweighted. JTT (Liu et al., 2021) trains via ERM for a few epochs, before training a second ERM model with incorrect datapoints upsampled. For image data sets, CIM (Taghanaki et al., 2021) trains transformation network to remove potentially spurious attributes from input features.
Contrastive learning (CL). CL works by predicting whether two imputs are "similar" or "dissimilar" (Le-Khac al., 2020). This involves specifying batches of anchor and positive datapoints similar to each other (as different "views"" of the same source or input), and negatives depicting dissimilar points. An encoder is trained to simultaneously maximize the similarity between the feature representations of anchors and positives, and minimize similarity between anchor and negative representations. In unsupervised CL. "negatives" are often sampled uniformly (Bachman et al., 2019), while "positives" different views of the same object, c.g. via data augmentation (Chen et al., 2020). In supervised points and positives are same-class points (Khosla et al., 2020). In
CL, negatives are different-claat CNC, we instead treat same-class points with differrnt ERM predictions as positives, and different- class points with the same ERM prediction as negatives. This naturally provides "hard negative mining." a challenge for standard CL (Robinson al., 2021; Wu et al., 2021; Chuang al., 2020).
7 CONCLUSION
We present CNC, two-stage CL approach to learn representations robust to spurious correlations. We theoretically analyze the connection between alignment and worst- grout vs. average-group losses, and show that CNC achieves SOTA near-SOTA worst-group accuracy across several benchmarks.
9

---

Under review as a conference paper at ICLR 2022
ETHICS STATEMENT
We hope that our work is another step towards the important goal of making machine learning models more fair and robust. However, while our work successfully improves worst-group accuracy, this is not necessarily an end-all be-all metric other fairness-basee metrics may be more suitable in certain settings. Also, misuse of metrics could lead to potential harm. To avoid these pitfalls, is important for practitioners to understand the limitations and tradeoffs of different metrics, including when applying methods such as ours.
REPRODUCIBILITY STATEMENT
We have submitted our code as part of the supplementary materials. The datasets we use are publicly available (with the exception of CMNIST which is modification of the standard MNIST dataset (LeCun et al., 2010); our code to generate this modified dataset is also included). addition to the details provided in Section 5, further implementation. dataset, and experimental details can be found in Appendix For the theory, we include complete proofs of all claims in Appendix B.
REFERENCES
Faruk Ahmed, Yoshua Bengio, Harm van Seijen, and Aaron C. Courville. Systematic generalisation with group invariant predictions. In ICLR, 2021.
Kartik Ahuja, Karthikeyan Shanmugam, Kush Varshney, and Amit Dhurandhar. Invariant risk minimization games. In International Conference on Machine Learning, pp. 145-155. PMLR, 2020.
Alexander Alemi, Ian Fischer, Joshua Dillon, and Kevin Murphy. Deep variational information bottleneck. arXiv preprint arXiv:1612.004110, 2016.
Martin Arjovsky and Léon Bottou. Towards principled methods for training generative adversarial networks. arXiv preprint arXiv: / 7048662,, 2017.
2017.
Martin Arjovsky, Léon Bottou, Ishaan Gulrajani, and David Lopez-Paz. Invariant risk minimization. arXiv preprint arXiv: 1907000997 2019.
Devansh Arpit, Stanistaw Jastrzebski, Nicolas Ballas, David Krueger, Emmanuel Bengio, Maxinder Kanwal, Tegan Maharaj, Asja Fischer, Aaron Courville, Yoshua Bengio, et al. A closer look at memorization deep networks. International Conference on Machine Learning, pp. 233-242. PMLR. 2017.
Philip Bachman, R Devon Hjelm, and William Buchwalter. Learning representations by maximiz- ing mutual information across views. In Advances in Neural Information Processing Systems, volume 32, 2019.
Ananth Balashankar, Alyssa Lees, Chris Welty, and Lakshminarayanan Subramanian. What is fair? exploring Pareto-efficiency for fairness constrained classifiers. arXiv preprint arXiv: 141200 2019.
Sara Beery, Grant Van Horn, and Pictro Perona. Recognition in terra incognita. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 456-473, 2018.
Aharon Ben-Tal, Dick Den Hertog, Anja De Waegenaere, Bertrand Melenberg, and Gijs Rennen. Robust solutions of optimization problems affected by uncertain probabilities. Management Science, 59(2):341-357, 2013.
Su Lin Blodgett, Lisa Green, and Brendan O'Connor. Demographic dialectal variation social media: A case study of african-american english. arXiv preprint arXiv:/608 08868, 2016.
Daniel Borkan, Lucas Dixon, Jeffrey Sorensen, Nithum Thain, and Lucy Vasserman. Nuanced metrics for measuring unintended bias with real data for text classification. In Companion proceedings of the 2019 world wide web conference, pp. 491-500, 2019.
10

---

Under review as a conference paper at ICLR 2022
Joy Buolamwini and Timnit Gebru. Gender shades: Intersectional accuracy disparities in commercial gender classification. In Conference on faimess, accountability and transparency, pp- 77-91. PMLR. 2018.
Jonathon Byrd and Zachary Lipton. What is the effect of importance weighting in deep learning? In International Conference on Machine Learning, pp. 872-881. PMLR, 2019.
Kaidi Cao, Colin Wei, Adrien Gaidon, Nikos Arechiga, and Tengyu Ma. Learning imbalanced datasets with aabelldistributionawweee margin loss. In Advances in Neural Information Processing Systems, volume 32, 2019.
Ting Chen, Simon Korbllihh, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pp. 1597-1607. PMLR, 2020.
Ching-Yao Yao Chuang, J. Robinson, Yen-Chen Lin, A. Torralba, and S. Jegelka. Debiased contrastive learning. Advances in Neural Information Processing Systems, volume abs/2007.000224 2020.
Remi Tachet des Combes, Mohammad Pezeshki, Samira Shabanian, Aaron Courville, and Yoshua Bengio. On the learning dynamics of deep neural networks. arXiv preprint 1809:08800008/ 2018.
Elliot Creager, Jörn-Henrik Jacobsen, and Richard Zemel. Environment inference for invariant learning. International Conference on Machine Learning, pp. 2189-2200. PMLR, 2021.
Yin Cui, Menglin Jia, Tsung- Yi Lin, Yang Song, and Serge Belongie. Blass-balanced loss based on effective number of samples. In Proceedings of the IÉEE/CVF Conference Computer Vision and Puttern Recognition, pp. 9268-9277, 2019.
Sebastian Curi, Kfir Y. Levy, Stefanie Jegelka, and Andreas Krause. Adaptive sampling for stochastic risk-averse learning. In Advances Neural Information Processing Systems, volume 33, pp. 2020.
John Duchi and Hongseok Namkoong. Variance-based regularization with convex objectives. The Journal of Machine Learning Research, 20(1):2450-2504, 2019.
Chen Fang, Ye Xu, and Daniel N Rockmore. Unbiased metric learning: On the utilization of multiple datasets and web images for softening bias. In Proceedings of the IEEE International Conference on Computer Vision, pp. 1657-1664, 2013.
Yaroslav Ganin, Evgeniya Ustinova, Hana Ajakan, Pascal Germain, Hugo Larochelle, François Laviolette, Mario Marchand, and Victor Lempitsky. Domain-adversarial training of neural networks. The journal of machine learning research, 17(1):209 2030, 2016.
Karan Goel, Albert Gu, Yixuan Li, and Christopher Ré. Model patching: Closing the subgroup performance gap with data augmentation. International Conference on Learning Representations, 2020.
Beliz Gunel, Jingfei Du, Alexis Conneau, and Ves Stoyanov. Supervised contrastive learning for pre-trained language model fine-tuning. International Conference on Learning Representations, 2021.
M. Gutmann and A. Hyvärinen. Noise-contrastive estimation: A new estimation principle for unnormalized statistical models. In AISTATS, 2010.
Tatsunori Hashimoto, Megha Srivastava, Hongseok Namkoong, and Percy Liang, Fairness without demographies in repeated loss minimization. In International Conference on Machine Learning. pp. 1938. PMLR, 2018.
Kaveh Hassani and Amir Hosein Khasahmadi. Contrastive multi-view representation learning graphs. International Conference on Machine Learning, pp. 4116-4126. PMLR, 2020.
Haibo He and Edwardo A Garcia. Learning from imbalanced data. IEEE Transactions on knowledge and data engineering, 21(3):1263112844 2009.
11

---

Under review as a conference paper at ICLR 2022
Katherine L. Hermann and Andrew K. Lampinen. What shapes feature representations? exploring datasets, architectures, and training. Advances in Neural Information Processing Systems (NeurIPS), 2020.
Shachar Kaufman, Saharon Rosset, Claudia Perlich, and Ori Stitelman. Leakage in data mining: Formulation, detection, and avoidance. ACM Transactions on Knowledge Discovery from Data (TKDD), 6(4):1-21, 2012.
Prannay Khosla, Piotr Teterwak, Chen Wang, Aaron Sarna, Yonglong Tian, Phillip Isola, Aaron Maschinot, Ce Liu, and Dilip Krishnan. Supervised contrastive learning. In Advances in Neural Information Processing Systems, volume 33, pp. 18661-18677 2020.
Pang Wei Koh, Shiori Sagawa, Sang Michael Xie, Marvin Zhang, Akshay Balsubramani, Weihua Hu, Michihiro Yasunaga, Richard Lanas Phillips, Irena Gao, Tony Lee, et al. Wilds: A benchmark of in-the-wild distribution shifts. International Conference on Machine Learning, pp. 5637-5664. PMLR, 2021.
David Krueger, Ethan Caballero, Joern-Hente Jacobsen, Amy Zhang, Jonathan Binas, Dinghuai Zhang, Remi Le Priol, and Aaron Courville. Out-of-distribution generalization via risk extrapola- tion (rex). arXiv preprint arXiv:2003.00688 2020.
Phuc H. Le-Khac, Graham Healy, and Alan F. Smeaton. Contrastive representation learning: A framework and review. IEEE Access, 8: 19999977-93393, 2020. doi: 10.1009//CEES.2000 3031549.
Yann LeCun, Bernhard Boser, John S Denker, Donnie Henderson, Richard E Howard, Wayne Hubbard, and Lawrence D Jackel. Backpropagation applied to handwritten zip code recognition. Neural computation, 1(4):541-551, 1989.
Yann LeCun, Corinna Cortes. and CJ Burges. MNIST handwritten digit database. ATT Labs [Online]. http:///ww..ecc.ccoo///ee///////
2010.
Daniel Levy, Yair Carmon, John C Duchi, and Aaron Sidford. Large-scale methods for distributionally robust optimization. Advances in Neural Information Processing Systems, volume 33, pp. 8847- 8860, 2020.
Haoliang Li, Sinno Jialin Pan, Shiqi Wang, and Alex C Kot. Domain generalization with adver- sarial feature learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5400-5409, 2018.
Evan Z Liu, Behzad Haghgoo, Annie S Chen, Aditi Raghunathan, Pang Wei Koh, Shiori Sagawa, Percy Liang, and Chelsea Finn. Just train twice: Improving group robustness without training group information. In International Conference on Machine Learning, pp. 6781-6792. PMLR, 2021.
Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Deep learning face attributes the wild. In Proceedings of the IEEE international conference on computer vision, pp. 3730-3738, 2015,
Natalia Martinez, Martin Bertran, and Guillermo Sapiro. Minimax pareto fairness: multi objective perspective. In International Conference on Machine Learning (ICML), 2020.
A. Mnih and K. Kavukcuoglu. Learning word embeddings efficiently with noise-contrastive estima- tion. In NIPS, 2013.
Vaishnavh Nagarajan, Anders Andreassen, and Behnam Neyshabur. Understanding the failure modes of out-of-distribution generalization. arXiv preprint arXiv:2010.15777 2020.
Junhyun Nam, Hyuntak Cha, Sungsoo Ahn, Jaeho Lee, and Jinwoo Shin. Learning from failure: De-biasing classifier from biased classifier. In Advances in Neural Information Processing Systems, volume 33, pp. 20673-20684, 2020.
Luke Oakden Oakden-Rayner, Jared Dunnmon, Gustavo Carneiro, and Christopher Ré. Hidden stratification causes clinically meaningful failures machine learning for medical imaging. In Proceedings of the ACM conference health, inference, and learning, pp. 151-159, 2020.
12

---

Under review as a conference paper at ICLR 2022
Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint 180.03378, 2018.
Yonatan Oren, Shiori Sagawa, Tatsunori B Hashimoto, and Percy Liang. Distributionally robust language modeling. In Empirical Methods in Natural Language Processing (EMNLP), 2019.
Giambattista Parascandolo, Alexander Neitz, Antonio Orvieto, Luigi Gresele, and Bernhard Schölkopf. Learning explanations that are hard to vary. arXiv preprint arXiv:2009.00329, 2020.
Mohammad Pezeshki, Sékou-Oumar Kaba, Yoshua Bengio, Aaron Courville, Doina Precup, and Guillaume Lajoie. Gradient starvation: A learning proclivity in neural networks. arXiv preprint arXiv:2011.09468, 2020.
Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. "why should trust you?" explaining the predictions of any classifier. In Proceedings of the 22nd ACM SIGKDD international conference on knowledge discovery and data mining, pp. 1135-1144 1144, 2016.
Robinson, Ching- Yao Chuang, S. Sra, and S. Jegelka. Contrastive learning with hard negative samples. In International Conference Learning Representations, 2021.
Kate Saenko, Brian Kulis, Mario Fritz, and Trevor Darrell. Adapting visual category models to new domains. In European conference on computer vision, pp. 213-226. Springer, 2010.
Shiori Sagawa, Pang Wei Koh, Tatsunori Hashimoto, and Percy Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. In International Conference on Learning Representations, 2019.
Shiori Sagawa, Aditi Raghunathan, Pang Wei Koh, and Percy Liang. An investigation of why overparameterizatton exacerbates spurious correlations. In International Conference Machine Learning, pp. 8346 8356. PMLR, 2020.
Ramprasaath R Selvaraju, Michael Cogswell, Abhishek Das, Ramakrishna Vedantam, Devi Parikh, and Dhruv Batra. Grad-cam: Visual explanations from deep networks via gradient-based local- ization. In Proceedings of the IEEE international conference on computer vision, pp. 618-626, 2017.
Pierre Sermanet, Corey Lynch, Yevgen Chebotar, Jasmine Hsu, Eric Jang, S. Schaal, and Sergey Levine. Time-contrastive networks: Self-supervised learning from video. 2018 IEFE International Conference on Robotics and Automation (ICRA), pp. 1134-1141, 2018.
Hidetoshi Shimodaira. Improving predictive inference under covariate shift by weighting the log- likelihood function. Journal of statistical planning and inference, 90(2):227-244, 2000.
Nimit Sohoni, Jared Dunnmon, Geoffrey Angus, Albert Gu, and Christopher Ré. No subclass left behind: Fine-grained robustness in coarse-grained classification problems. In Advances Neural Information Processing Systems, volume 33, pp. 19339-19352, 2020.
Jiaming Song and Stefano Ermon. Multi-label contrastive predictive coding. In Advances in Neural Information Processing Systems, volume 33, pp. 8161-8173, 2020.
Saeid Asgari Taghanaki, Kristy Choi, Amir Khasahmadi, and Anirudh Goyal. Robust representation learning via perceptual similarity metrics. arXiv preprint arXiv:2 06620, 2021.
Yonglong Tian, Dilip Krishnan, and Phillip Isola. Contrastive multiview coding. arXiv preprint 1eXiv:1906.05300 2019.
Yonglong Tian, Chen Sun, Ben Poole, Dilip Krishnan, Cordelia Schmid, and Phillip Isola. What makes for good views for contrastive learning. arXiv preprint 1022: 2020.
Julius von Kügelgen, Yash Sharma, Luigi Gresele, Wieland Brendel, Bernhard Schölkopf. Michel Besserve, and Francesco Locatello. Self-supervised learning with data augmentations provably isolates content from style. arXiv preprint (0t.:2/000046//9 2021.
Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie. The caltech-ucsd birds-200-2011 dataset. 2011.
13

---

Under review as a conference paper at ICLR 2022
Rui Wang, Zuxuan Wu, Zejia Weng, Jingjing Chen, Guo-Jun Qi, and Yu- Yu-Gang Jiang. Cross-domain contrastive learning for unsupervised domain adaptation. arXiv preprint arXiv:2106.05528, 2021.
Tongzhou Wang and Phillip Isola. Understanding contrastive representation learning through align- ment and uniformity on the hypersphere. In International Conference on Machine Learning, pp. 9929-9939. PMLR, 2020.
Zhou Wang, Eero P Simoncelli, and Alan C Bovik. Multiscale structural similarity for image quality assessment. In The Thrity-Seventh Asilomar Conference on Signals, Systems & Computers, 2003, volume 2, pp. 1398-1402. Icee, 2003.
Wolfram Wiesemann, Daniel Kuhn, and Melvyn Sim. Distributionally robust convex optimization. Operations Research, 62(6))1358-13700 2014.
M. Wu, M. Mosse, Chengxu Zhuang, D. Yamins, and Noah D. Goodman. Conditional negative sampling for contrastive learning of visual representations. In International Conference Learning Representations, 2021.
Zhilu Zhang and Mert Sabuncu. Generalized cross entropy loss for training deep neural networks with noisy labels. Advances in Neural Information Processing Systems, volume 31, 2018.
Bolei Zhou, Agata Lapedriza, Aditya Khosla, Aude Oliva, and Antonio Torralba. Places: A 10 million image database for scene recognition. IEEE transactions pattern analysis and machine intelligence, 40(6)):
2017.
Jun- Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. Proceedings of the IEEE international conference on computer vision, pp. 22-2222222223 2017.
14

---

Under review as a conference paper at ICLR 2022
A ADDITIONAL BENCHMARK COMPARISONS AND ABLATIONS
In this section, we include further experiments comparing CNC against additional related methods. We also include additional ablations to study the importance of CNC's presented design choices.
A.1 COMPARISON TO MINIMIZING THE ALIGNMENT LOSS DIRECTLY
In Sec. 5.1 and Sec. 5.2, we empirically showed that CNC's contrastive loss and hard positive and negative sampling lead to improved worst-group accuracy and greater representation alignment. We now study how CNC performs if instead of the contrastive loss, we train the Stage 2 model to minimize Lalign directly. With this objective, we aim to minimize the Euclidean distance between samples in different inferred groups but the same class. We keep all other components of CNC consistent, and apply Lalign to the anchor and positive samples in each contrastive batch. We report results on CMNIST*, Waterbirds, and CelebA in Table A.1.
Table A.I: Across benchmarks, CNC achieves higher worst-group and average accuracies with the default contrastive loss, compared to using the alignment loss explicitly training objective.
Method
CelebA Worst-group Average Worst-group Average Worst-group Average
CMNIST
Waterbirds
Accuracy (%)
CNC (fallgg)
67.3 (3.1) 83.7 (1.1) 83.3 (0.8)
89.4 (0.2)
84.6 (0.5) 88.0 (0.3)
CNC (default contrastive)
77.4 (3.0) 90.9 (0.6) 89.7 (0.2) 90.8 (0.1)
88.8 (0.9) 89.9 (0.5)
We find that CNC with the default contrastive loss outperforms CNC with the alignment loss. We reason that an ad advantage of the contrastive loss (and specifically the "hard" positive and negative samples), is that it encourages aligning samples with the same class label but different spurious features, and pushes apart hard negative samples with different class labels but similar spurious features. This provides additional signal for improving separation between the different classes, so the robust model only learns to rely on ground twwth-ruuucchiiee features for discriminating between datapoints. On the other hand, the Lalignment objective does not incorporate these hard negatives.
A.2 COMPARISON TO REPRESENTATION ALIGNMENT METHODS FOR DOMAIN GENERALIZATION AND ADAPTATION
While our main results in Table 1 compare against methods designed to tackle the spurious correlations setting presented in Section 5.1, we now study how CNC fares against existing representation alignment methods proposed in the domain generalization (DG) and unsupervised domain adaptation (UDA) literature. At high level, a popular idea in DG and UDA to learn similar representations for datapoints with the same class but sampled from different domains, e.g. via adversarial training to prevent another model from classifying representations' source domains correctly (Ganin et al., 2016). or minimizing representation differences via metrics such maximum mean discrepancy (MMD) (Li et al., 2018). While DG and UDA carry distinct problem settings and assumptions from our spurious correlations setting (c.f. Appendix D.4), aim to understand if existing representation alignment methods can train models robust to spurious correlations, and compare their performance with CNC. We first explain our protocol for evaluating these methods, and then discuss results.
We carry out our evaluation with donain-adversarial neural networks (DANN) Ganin et al. (2016), seminal UDA method that aims to learn aligned representations actoss two domains. To do so, DANN jointly trains a model to classify samples from a "source" domain while preventing separate "domain classifier" module from correctly classifying the domain for datapoints sampled from both domains. For fair comparison, we use the same ResNet-50 backbone as in CNC, and make several adjustments to the typical DANN and UDA procedure:
1. While UDA assumes that the data is organized into "source" and "target" domains, do not have domain labels. We thus infer domains using the predictions of an initial ERM model as in CNC.
2. The notion of a domain may also be ambiguous with respect to the groups defined in Section 2. For example, domains may be defined by spurious attributes (e.g., for the Waterbirds dataset,
15

---

Under review as a conference paper at ICLR 2022
may consider the "water background" domain and the "land background" domain). Domains may alternatively be defined by whether samples carry dominant spurious correlations or not (e.g.. the "majority group" domain and the "minority group" domain). We train and evaluate separate DANN models for both interpretations. We infer the former by the predicted class of the initial ERM model. We infer the latter by whether the initial ERM model is correct or not.
3. Finally, UDA aims to train with class-labeled "source" domain and an unlabeled "target" domain such that a model performs well on unseen samples from the specified "target" domain (Ganin et al., 2016). However, our benchmarks have class labels for all training points, and do not have a notion of "source" and "target" domains (we aim to obtain high worst-group accuracy, which could fall under any domain). We thus assume access to labels for all domains. During training, the goal for our DANN models is to correctly classify samples from both domains, while learning representations such that jointly trained domain classifier module cannot determine the samples' domains from their representations alone. At test-time, we evaluate the DANN model on the entire test set for each benchmark, and report the worst-group and average accuracies.
Table A.2: CNC achieves higher gorst-group and average accuracies on spuriously correlated benchmarks than DANN, a prior representation alignment method designed for domain adaptation
Method
Waterbirds
CelebA
Accuracy (%)
Worst-group Average Worst-group Average
DANN (domains by spurious attribute)
37.4 (3.8) 87.6 (2.2) 28.1 (3.1) 94.6 (0.3)
DANN (domains by majority vs minority group)
67.3 (0.8)
83.6 (0.2)
47.2 (3.1)
88.7 (1.8)
CNC
89.7 (0.2) 90.8 (0.1)
88.8 (0.9)
89.9 (0.5)
In Table A.2, we report the worst-group and average accuracies of DANN on the Waterbirds and CelebA datasets across three seeds along with the CNC results. Our results suggest that the domain alignment in DANN is not sufficient to improve worst-group accuracy. We hypothesize this is due to adversarial training with the domain classifier aligning representations without regard to different classes within each domain. Due the propensity of samples exhibiting spurious correlations, DANN models may thus still learn to rely on these correlations.
A.3 IMPORTANCE OF ERM-GUIDED CONTRASTIVE SAMPLING
In this section we conduct additional ablations on the sampling procedure in CNC. Although CNC relies on an initial trained ERM model's predictions, can we still improve worst-group accuracy without this step and with supervised contrastive learning alone, i.e. by sampling positives uniform randomly from all datapoints with the same label as the anchor? In Table 1, we showed that this approach (denoted SupCon") led to a drop in worst-group accuracy. Taking this question further, while we use the Stage 1 ERM model's predictions to sample "hard" negatives with different ground- truth classes and the same ERM predictions as their anchors such that to reduce the contrastive loss and learn dissimilar representations for anchors and negatives, the Stage 2 contrastive model must thus learn to ignore spurious features that the initial ERM model learns to depend on onwhow does CNC's performance fare with alternative negative sampling procedures? Keeping the anchor and positive sampling consistent, we perform additional ablations where we either sample negatives only by having different classes as their anchors, or sample negatives only be having the same ERM model prediction as their anchors. We report these results in Table A.3 below.
We find that the default CNC sampling procedure obtains highest worst-group accuracy and highest or near-highest average accuracy compared to alternative strategies across the CMNIST", Waterbirds, and CelebA datasets. The results suggests that inferring the spurious attributes (e.g. via an initial ERM model) is important for CNC, and that CNC benefits from using these predictions for sampling both negatives and positives. We reason this is because without this sampling, we can actually encourage the Stage 2 model to rely on spurious correlations. For example, if we just ensure that the anchor and negative samples have different classes, then the contrastive model may just rely on the different spurious features of the anchors and negatives to learn dissimilar representations. However, by ensuring that the anchors and negatives have similar spurious features (via the same trained ERM model prediction), the contrastive model is forced to rely on non-spurious features to learn dissimilar
16

---

Under review as a conference paper at ICLR 2022
Table A.3: Ablation positive and negative sampling strategies in CNC. CNC achieves highest gorst-group accuracy when using the Stage ERM model's predictions to sample "hard" positives and negatives (the default procedure).
Method
CMNIST
Waterbirds
CelebA
Accuracy (%)
gorst-group Average Worst-group Average Worst-group Average
Negatives by different class
66.4 (5.1) 86.0 (1.6) 82.2 (0.8)
88.9 (0.3) 79.2 (0.3) 88.0 (0.1)
Negatives by same prediction
70.0 (5.1) 87.1 (1.1)
85.7 (1.3)
90.3 (0.2)
81.1 (1.4)
88.5 (0.3)
SupCon*
(0.0)
22.4 (1.2)
71.9
85.9 (0.8) 62.2 (1.1)
90.0 (0.1)
CNC (default)
77.4 (3.0)
90.9 (0.6)
89.7 (0.2)
90.8 (0.1) 88.8 (0.9)
89.9 (0.5)
representations for the samples. The same logic applies for learning similar representations for anchor and positive samples. We suspect that choosing negatives from samples with the same ERM prediction as their anchors performs better than the other ablations as it alone does not encourage learning spurious correlations: the model asked to "pull apart" samples with the same spurious features, and so must ignore spurious similarities recognize something different between anchors and negatives. However, this ablation does not ensure that anchor- nightrveeeative pairs consist of different classes (which our full method does), so the model gets less signal to separate samples by class.
A.4 ADDITIONAL. DESIGN CHOICE ABLATIONS
We first summarize CNC's design choices and differences from standard supervised contrastive learning in Appendix 1.4.1. We then empirically validate each component in Appendix A.4.2.
1.4.1 1 SUMMARY OF CNC DESIGN CHOICES AND PROPERTIES
No projection network. As wish to learn data representations that maximize the alignment between anchor and positive datapoints, we do not compute the contrastive loss with the outputs of an additional nonlinear projection network. This is inspired by the logic justifying a projection head in prior contrastive learning, e.g. SimCLR (Chen et al., 2020), where the head is included because the contrastive loss trains representations be "invariant to data transformation" and may encourage removing information "such as the color or orientation of objects". In our case, we view inferred datapoints with the same class but different spurious attributes as "transformations" of each other, and we hypothesize that removing these differences can help us improve worst-group performance.
Two-sided contrastive sampling. To incorporate additional comparisons between datapoints that only differ in spurious attribute during training, we employ "two-sided" contrastive batch sampling. This lets us equally incorporate instances where the second contrastive model in CNC treats datapoints that the initial ERM model got incorrect and correct anchors.
Additional intrinsic hard positive/negative mining. Because the new model corrects for potentially learned spurious correlations by only comparing and contrasting datapoints that differ in class label or spurious attribute, but not both (as dictated by the initial ERM model's outputs), the contrastive batches naturally carry "hard" positives and negatives. Thus, our approach provides natural form of hard negative mining (in addition to the intrinsic hard positive/ negative mining at the gradient level with InfoNCE- contrastive losses (Chen et al., 2020; Khosla et al., 2020)) while avoiding class collisions, two nontrivial challenges in standard self-supervised contrastive learning (Robinson et al., 2021; Wu et al., 2021; Chuang et al., 2020).
Joint training of encoder and classifier layers. CNC can train any standard classification model architecture; for any given neural network we just apply different optimization objectives to the encoder and classifier layers. We train both the encoder and classifier layers with a cross-entropy loss, and jointly train the encoder layer with a supervised contrastive loss. For the encoder layers, we balance the two objectives with hyperparameter À (c.f. Eq. 7).
A.4.2 EMPIRICAL VALIDATION OF CNC COMPONENTS
To validate the additional algorithmic components of CNC, we report how CNC performs on the Waterbirds dataset when modifying the individual design components. We use the same hyperpa-
17

---

Under review as a conference paper at ICLR 2022
rameters as in the main results, and report accuracies the average three training runs for the following ablations. Table A.4 summarizes that across these design ablations, default CNC as presented consistently outperforms these alternative implementations.
Table A.4: Ablation over CNC algorithmic components on Waterbirds. Default choices achieve highest worst-group and average accuracy.
Method
CNC (Default) Projection Head
One-sided Contrasting
Train + Finetune
WG Acc. (%)
89.7 (0.2)
82.4 (1.8)
85.2 (3.6)
84.0 (1.7) 87.7 (1.1)
Avg. Acc. (%)
90.8 (0.1)
88.7 (0.6)
90.1 (1.6)
No projection head. We incorporate a nonlinear projection head as is typical in prior contrastive learning works (Chen al., 2020), that maps the encoder output to lower-dimensional representations (from 2048 to 128 in our case). We then update the encoder layers and the projection head jointly by computing the contrastive loss on the projection head's output, still passing the encoder layer's direct outputs to the classifier to compute the cross-entropy loss. We note that using the projection head decreases worst-group accuracy substantially. We reason that as previously discussed, while using the projection head in prior work can allow the model to retain more information in its actual hidden layers (Chen et al., 2020), in our case to remove dependencies on spurious attributes we actually want to encourage learning invariant representations when model the differences between anchor and positive datapoints as due to spurious attributes.
Two-sided contrastive batches. Instead of "two-sided" contrasting where we allow both sampled anchors and positives to take on the anchor role, for each batch we only compute contrastive updates by comparing original positives and negatives with the original anchor. When keeping everything else the same, we find that just doing these one-sided comparisons also leads to a drop in performance for worst-group accuracy. This suggests that the increased number of comparisons and training setup where we swap the roles of anchors and positives of the two-sided batches introduces greater contrastive learning signal.
Additional intrinsic hard positive/negative mining, We discuss this ablation in Section A.3.
Joint training of encoder and classifier layers. Instead of training the full model jointly, we first only train the encoder layers with the contrastive loss in CNC, before freezing these layers and finetuning the classifier layers with the cross-entropy loss. With this implementation, we also obtain noticeable drop in performance. While we leave further analysis for the joint cross-entropy and contrastive optimization for future work, one conjecture that the cross-entropy loss may aid in learning separable representations while also training the full model to keep the average error small. From our theory, the contrastive loss can help bound the gap between worst-group and average error. Thus try minimize average error in the same parameter update.
This also follows prior work, where updating the entire model and finetuning all model parameters instead of freezing the encoder layers leads to higher accuracy (Chen et al., 2020). However, found that with an initial encoder-only training stage, if we did not freeze the trained layers the fine-tuning dataset with spurious correlations would "revert" the contrastive training, resulting in a large gap between worst-group and average error similar to ERM.
We also ablate the balancing hyperparameter of CNC CMNIST". In Table A.5 we find that CNC consistently achieves high worst-group accuracy across a wide range of À E [0.4, 0.9). For reference, the next best methods GEORGE and JTT obtain 76.4% and 74.5% worst-group accuracy.
Table A.5: Ablation over CNC X parameter to balance cross-entropy and contrastive loss components on CMNIST CNC obtains high performance across a range of X.
C
0.2
0.4
0.6
0.8
0.9
Robust Acc.
70.4 (2.9)
74.2 (2.6)
75.3 (1.7)
77.4 (2.5)
75.8 (1.2)
Average Acc.
89.0 (0.
88.0 (0.7)
88.3 (0.6)
89.9 (0.4)
88.4 (0.1)
18

---

Under review as a conference paper at ICLR 2022
B OMITTED PROOFS FROM SECTION 3.2
In this section, we prove that within any class, the gap between the worst-group enror and the average eπrоr can be upper bounded by the alignment loss times the Lipschitz constant, plus another concentration error term.
Proof of Theorem 3.1. Consider two arbitrary groups, denoted by 91 (y. 01) and 92 (y. 02). whose class labels are both E V whose spurious attributes are d1 E AA and d2 E A such that a1 # 02- Let G1 and G2 be the subset of training data that belong groups ya and 92, respectively. We note that both G₁ and G2 are non-empty since we have assumed that (in Section 2) there is at least one sample from each group in the training data Let ng. [G1] and Rgg G2 be the size of these two groups, respectively. Recall that fenc denotes the mapping of the encoder layers of the full neural network model fo. Since the classification layer fets is a linear layer, have used W to denote the weight matrix of this layer. Our definition of the cross cross-group alignment loss in equation (5), denoted as Latign (So: fo; v), implies that for 91 and J2.
1
Σ
Σ [l fenc (22) S Caliga (f:
Rg1 Oga (R.9.01)EG, (2',vRo)EG.
Next, let E(2,y,01~~PP aGv (W (eno(a)), be the average loss conditioning on data point being sampled from group 91 (and similarly for group 92). Let (g)),9)) be the difference between the population average losses:
A(g1
E (a..y.a) ) PrPo
Lav (W
Senc (x),
E (Lau (W Semc (2),
(r.y.az)~PPp3
Recall that Gy G is the set groups that have class label y. Since the loss E(-) is bounded above by some fixed constant C2 according to assumption, and is at least zero, by the Hoeffding's 's inequality, the following result holds with probability at least 6, for all |Gyl groups E Gy.
2 log (1g)1/0)
(Cavg Sene (x), Tg (x,)))(X,Y)
Σ
E(W ((neen())))))
C22
(2.y.e)~/P,
fg
Thus, with probability at least 5, the following holds for any I1 and g2 in class y (but having different spurious attributes)
Agg (01
S
1
Σ
Lavg (W (eno (x).
Σ
Lavg feno
(10)
Thax (a.MaL))E.
Th (w* (oa))aa))G.
(v/
22 (y1/5)
2 (og((9y1/5)
+ C2
+
Rg1
Tgga
Next, we focus the RHS of equation (10). First, equation (10) is also equal the following:
Σ
Σ
E(W fene((),
Σ Σ
e(W (20c
Thg1 Tu22 (Z.g,a1)EGs (a' E..2))G22
Tgg Th (n. (x' (za)).2))
Since we have also assumed that the loss function f(x, y) C1 -ipLishciizz in x², the above is at most:
1
Σ
Σ
(ono (( Senc (a'((()) ))1l
Rgg gz (D.aa))EG (a' EGa
1
Σ
Σ
C [en (x: - W Wene(a")) 122
(since y is the same for æ, x²)
Dgg figa (#.8a))EG, (a' E.2
B
Σ
Σ
C1 (x) fene(x'))
(because ||]] < B as assumed)
Og Roga (2.0,a1)E, (a' e.o2)e2
<B C Latign (fo:.).
(because of equation (8))
In other words, that (f(2.)) 0(2',))) ) C. 112 2' z'1la, for any 2' and y.
19

---

Under review as a conference paper at ICLR 2022
Thus, have shown that for any I1 and 92 within class y,
Ag 92) S B (faign + (v)
2 (ogg(19))1 (8)
2 log(
llog(1yl /0)
+
ngg
ngga
[og((191/0)
S B C1 Latign (fo; 8) + max
C2 gE9,
(11)
"gg
Finally, we use the above result to bound the gap between the worst-group loss and the average loss. For every group 9 E 9, let Pg denote the prior probability of observing a sample from P in this group. Let qy = Eg'eg, Py Let h(g) be a short hand notation for
h(g)
E
[L (W Senc (x),
(2.g.a)~P,
Ps h(g). The worst- The average loss among the groups with class label is Lavg Eang(Oo;)) = Egee, 95 group loss among the groups with class label y/ is (un((oo)) maxgec, h(g). Let g" be a group that incurs the highest loss among groups in Gy. We have Logg (fo: Lang (fo; v) is equal to
h(g²)
Σ gE9v
Pa h(g))
Σ
Pa (h(g") -h(g)
(12)
qy
4y
g gEg.
Σ
Pg A(g",
(13)
dy
SEG,
log((G) /8)
< B C Lagga fo: 8) + max C2
(14)
gEG,
ng
The last step uses equation (11) on A g)) and the fact that dy Eg Eg' Par Thus, we have shown that the gap between the worst-group loss and the average loss among the groups with the same class
label bounded by the above equation. The proof is now complete.
The astute reader will note that Theorem 3.1 focuses comparing groups within the same class for any E V. A natural follow-up question is what happens when comparing across groups with different labels. Let (fe) maxzey Lug(fe:) y) be the group loss across all the labels. Recall that Lavg (Jo) is the average loss for the entire population of data. We generalize Theorem 3.1 to this setting in the following result.
Corollary B.1 (Extension of Theorem 3.1 to compare across different classes). In the setting of Theorem 3.1, let qy Egges, Pg be the prior probability of observing a sample drawn from P with label y. for any y E Y. We have that with probability at least 5, the following holds:
8 Blog(19) (5) (15)
Lwg(Fo) 5 imingy) yE)
(fn + B C1
max Latign (.fo : y)
max C2 9EG
yEY
R2g
Proof. We generalize the argument in the previous result to compare across different labels. The worst-group loss across different labels
max max ((()) yEY gESr
< max yey
Σ 9E9,
Pa Pa)lg) B- Ca (fo:v) - max Cz gEG,
8 Bogg(G (og(())l/))) 18)
(because of equation (14))
IN
log( (9188) ng
Σ Pol((g) +B max Lange (Seiv) v) max Ca mingey 4u gEG,
wEY
Since EnEg Pgg(()) Lavg (Jo), we thus conclude that
8 logg( [ /8)
Cug(fo) <
min 4y yEy
Lme(fo) C₁ max Los max C2
DEy
gEG
Vgg
The proof is complete.
20

---

Under review as a conference paper at ICLR 2022
An example showing that Corollary B.1 is tight. We describe simple example in which the factor mingey fy -1
in equation (15) is tight (asymptotically). Suppose there are perfectly balanced classes that By 1/k: for every y E V. There is data point from each class, with loss equal to 0 for all except one of them. The worst-group loss is I whereas the average loss is 1/k. Thus, there is a factor of between the worst-group loss and the average loss. For equation (15), the factor
min By yEyy
=k,
since Qy = 1/k for every y E y in this example. Thus, this factor matches the (multiplicative) factor between the worst-group loss and the average loss in this example.
C CONTRASTIVE ALGORITHM DESIGN DETAILS
In this section, we provide further details on the training setup and contrastive batch sampling, pseudocode, and additional properties related to CNC's implementation.
C.I TRAINING SETUP
In Fig. 8, illustrate the training stages of Correct-N-Contras described in Sec. 4. In Stage 1, we first train an ERM model with a cross-entropy loss. For consistency with Stage 2, we depict the output as a composition of the encoder and linear classifier layers. Then in Stage a new model with the same architecture using contrastive batches sampled with the Stage ERM model and supervised contrastive loss (3) (which first normalized) to update the encoder layers. Note that unlike prior work in contrastive learning (Chen al., 2020; Khosla al., 2020), as we have the class labels of the anchors, positives, and negatives, we also continue forward- passinng the unnormalized representations (encoder layer outputs) and compute cross-entropy loss update the classifier layers while jointly training the encoder.
train
compute after the depicted representations are
Loss Function
Forward Pass
Backward Pass
Stage 1: ERM training
Stage Correct-N-Contran
"Wateriird"
"Waterbird"
"Waterbird"
"Landbird"
Cross-entropy
Cross-entropy
2-D
(.ts()
fols()
Contrastive
Contrastive
2048-D
Senc (.)
fenc
Input
Positive
Anchor
Negative
Figure 8: The two stages Correct-N-Cotrast. In Stage we train a model with standard ERM and a cross-entropy loss. Then in Stage 2, we train a new model with the same architecture, but specifically learn cattoous-atribuu-iinvnaa
representations with contrastive loss (3) and batches of anchors, positives, and negatives sampled with the ERM model's predictions. We also update the full model jointly with cross-entropy loss on the classifier layer output and the input class labels. Dimensions for ResNet-50 and Waterbirds.
We also note that unlike prior work, we wish to learn invariances between anchors and positives that maximally reduce the presence of features not needed for classification. We thus do not pass
21

---

Under review as a conference paper at ICLR 2022
{ 1 M
S ==1
0
{ f m=1
M
0 O
{ { n. In=1
-N- .N
6
5
4 0
9
6
0 0
8
{ n. J nn=1
1 ] V
8 8
0
0
0
9
(a) Contrastive Batch
(b) Two-sided Update
Figure 9: Illustration of two-sided contrastive batch sampling with Colored MNIST as an example. From a single batch (a), we can train a contrastive model with two anchor- anchor-posittve- (b). Aside from increasing the number of "hard negatives" for each aachor-positiee pair, this intuitively "pushes" together anchors and positives from two different directions for greater class separation.
pairings
the representations through additional projection network (Chen et al., 2020). Instead, Eq. to compute the supervised contrastive loss directly on the encoder outputs = (en)(r). In Appendix A.4.2, studied ablations with both design choices.
C.2 TWO-SIDED CONTRASTIVE BATCH IMPLEMENTATION
We provide more details on our default contrastive batch sampling approach described in Sec. 4. To recall, for additional contrastive signal per batch, we can double the pairwise comparisons in a training batch by switching the anchor and positive roles. This is similar to the NT-Xent loss in prior contrastive learning work (Chen et al., 2020). We switch the role of the anchor and first positive sampled in contrastive batch, and sample additional positives and negatives using the same guidelines but adjusting for the "new" anchor. We denote this as "two-sided" sampling in contrast with the "one-sided" comparisons we get with just the original anchor, positives, and negatives.
Implementing this sampling procedure practice simple. First, recall our initial setup with trained ERM model fa. its predictions { J training data {(z,, })}= (where number positives and negatives to sample M and N. We then sample batches with Algorithm 2.
fz(x:)), and
Because the initial anchors are then datapoints that the ERM model gets correct, under our heuristic we infer {2;), } as samples from the majority group. Similarly the M positives { 1 and N negatives {.55 J that it gets incorrect are inferred to belong to minority groups.
For one batch, we then compute the full contrastive loss with IN Gsup (fene) = Čsup (I1, ( {., 1i fene) + Loup (at (a (a/ (a=iismn) (16)
where Loun (I1: { JM= (2 : is given by:
M
exp(2] /T)
log IM exp(=] =t/ ) exp(=T ///
(17)
N
Algorithm 2 Sampling two-sided contrastive batches
Require: Number of positives M and number of negatives N to sample for each batch.
1: Initialize set of contrastive batches B = 0
2: for each v; (2; E X Ú: =y do
3: Sample M additional "anchors" to obtain [a;]M from {a, E X : 9: = --}
4: Sample M positives { 1M from { E X fmm = 91 ym $ y1
5: Sample negatives (*, 1. from { E X D = -is yn, + y;}
6: Sample N negatives {œ/, J from {ar E X : V/ = - ト
7: Update contrastive batch set: B +- BU [m
1M 12 J i (2/ IN
Jn=1
22

---

Under review as a conference paper at ICLR 2022
and again let be the normalized output (a) for corresponding We compute the cross-entropy component of the full loss for each x in the two-sided batch with its corresponding label y.
D FURTHER RELATED WORK DISCUSSION
We provide additional discussion of related work and connections to our work below.
D.I IMPROVING ROBUSTNESS TO SPURIOUS CORRELATIONS
Our core objective is to improve model robustness to group or subpopulation distribution shifts that arise from the presence of spurious correlations, specifically for classification tasks. Because these learnable correlations hold for some but not all samples in a dataset, standard training with ERM may result in highly variable performance: model that classifies datapoints based spurious correlations does well for some subsets or "groups" of the data but not others. To improve model robustness and avoid learning spurious correlations, prior work introduces the goal to maximize worst-group accuracy (Sagawa et al.. 2019). Related works broadly fall under two categories:
Improving robustness with group information. If information such spurious attribute labels is provided, one can divide the data into explicit groups as defined in See. 2, and then train to directly minimize the worst group-level error among these groups. This is done in group DRO (GDRO) (Sagawa et al., 2019), where the authors propose an online training algorithm that focuses training updates over datapoints from higher-loss groups. Goel et al. (2020) also adopt this approach with their method CycleGAN Augmented Model Patching (CAMEL). However, similar to our motivation, they argue that a stronger modeling goal should be placed on preventing a model from learning group-specific features. Their approach involves first training a CycleCAN (Zhu et al., 2017) to learn the data transformations from datapoints in one group to another that share the same class label. They then apply these transformations as data augmentations to different samples, intuitively generating new versions of the original samples that take on group-specific features. Finally they train a new model with a consistency regularization objective to learn invariant features between transformed samples and their sources. Unlike their consistency loss, we accomplish similar objective learn group-invariant features with contrastive learning. Our first training stage is also less expensive. Instead of training a CycleGAN and then using it to augment datapoints, we train a relatively simple standard ERM classification model, sometimes with only a few number of epochs, and use its predictions to identify pairs of datapoints to serve a similar purpose. Finally, unlike both CAMEL and GDRO, we do not require spurious attribute or group labels for each training datapoints. We can then apply CNC in less restrictive settings where such information is not known.
Related to GDRO are methods that aim to optimize a "Pareto-fair" objective, more general than simply the worst-case group performance. Notable examples are the works of Balashankar et al. (2019) and Martinez et al. (2020). However, these approaches similarly do not directly optimize for good representation alignment (unlike work).
Improving robustness without training group information. More similar to our approach are methods that do not assume group information at training time, and only require validation set spurious attribute labels for fine-tuning. As validation sets are typically much smaller in size than training sets, an advantage of CNC and comparable methods is that we can improve the accessibility of robust training methods to a wider set of problems. One popular line of work is distributionally robust optimization (DRO), which trains models to minimize the worst loss within a ball centered around the observed distribution (Ben-Tal Tal et al., 2013; Wiesemann et al., 2014; Duchi & Namkoong, 2019; Levy et al., 2020; Curi al., 2020; Oren et al., 2019). This includes the CVaR DRO (Levy et al.. 2020) method we evaluate against. However, prior work has shown that these approaches may be too pessimistic, optimizing not just for worst-group accuracy but worst possible accuracy within the distribution balls (Sagawa et al., 2019), or too undirected, optimizing for too many subpopulations, e.g. by first upweighting minority points but then upweighting majority points in later stages of training (Liu et al., 2021). Pezeshki et al. (2020) instead suggest that gradient starvation (GS), where neural networks only learn to capture statistically dominant features in the data (Combes et al., 2018), is the main culprit behind learning spurious correlations, and introduce "spectral decoupling" regularizer to alleviate GS. However this does not directly prevent models from learning dependencies on spurious attributes. Similar to CAMEL, Taghanaki et al. (2021) propose Contrastive Input Morphing
23

---

Under review as a conference paper at ICLR 2022
(CIM), image dataset-specific method that aims to learn input feature transformations that remove the effects of spurious or task iiselirreleaant attributes. They do so without group labels, training a transformation network with triplet loss to transform imput images such that a given transformed image's structural similarity metric (based on luminance, contrast, and structure (Wang et al., 2003)) is more similar to a "positive" image from the same class than a "negative" image from different class. They then train a classifier on top of these representations. Instead of pixel-level similarity metrics, CNC enforces similarity in a neural network's 's hidden-layee representations, allowing CNC to apply to non- con-image modalities. Additionally, we sample positives and negatives not just based on class label, but also the learned spurious correlations of an ERM model (via its trained predictions). We hypothesize that our sampling scheme, which intuitively provides "harder" positive and negative examples, allows CNC to more strongly overcome spurious correlations.
Most similar to our approach are methods that first train an initial ERM model with the class labels as a way to identify data points belonging to minority groups, and subsequently train an additional model with greater emphasis on the estimated minority groups. Sohoni et al. (2020) demonstrate that even when only trained on the class labels, neural networks learn feature representations that can be clustered into groups of data exhibiting different spurious attributes. They use the resulting cluster labels as estimated group labels before running GDRO on these estimated groups. Meanwhile, Nam et al. (2020) train a pair of models, where one model minimizes a generalized cross-entropy loss (Zhang & Sabuncu, 2018), such that the datapoints this model classifies incorrectly largely correspond to those in the minority group. They then train the other model on the same data but upweight the minority-groupe group-estimated points. While they interweave training of the biased and robust model, Liu al. (2021) instead train one model first with a shortened training time (but the standard cross-entropy objective), and show that then upsampling the incorrect data points and training another model with ERM can yield higher gorst-group accuracy. Creager et al. (2021) first train an ERM model, and then softly assign the training data into groups under which the initial trained ERM model would maximally violate the invariant risk minimization (IRM) objective. In particular, the IRM objective is maximally satisfied if model's 's optimal classifier is the same across groups (Arjovsky et al., 2019), and EIIL groups are inferred such that the initial ERM model's 's representations exhibit maximum variance within each group. Finally, Nagarajan et al. (2020) provides theoretical understanding of how ERM picks up spurious features under data set imbalance. They consider a setting involve a single spurious feature that is correlated with the class label and analyze the max-margin classifier in the presence of this spurious feature.
In our work, we demonstrate that the ERM model's predictions can be leveraged not only estimate groups and train new model with supervised learning but with different weightings. Instead, we can specifically identify pairs of points that a contrastive model can then learn invariant features between. Our core contribution comes from rethinking the objective with contrastive loss that more directly reduces the model's ability to learning spurious correlations.
D.2 CONTRASTIVE LEARNING
Our method also uses contrastive learning, a simple yet powerful framework for both self-supervised (Chen et al., 2020; Oord et al., 2018; Tian al., 2019; Song & Ermon, 2020; Sermanet al., 2018; Hassani & Khasahmadi, 2020; Robinson et al., 2021) and supervised (Khosla et al., 2020; Gunel al., 2021) representation learning. The core idea is to learn data representations that maximize the similarity between a given input "anchor" and distinct different views of the same input ("positives"".. Frequently this also involves contrasting positives with "negative" data samples without any assumed relation to the anchor (Bachman et al., 2019). Core components then include some way to source multiple views, e.g. with data transformations (Chen et al., 2020), and training objectives similar to noise contrastive estimation (Gutmann & Hyvärinen, 2010; Mnih & Kavukcuoglu, 2013).
An important component of contrastive learning is the method by which appropriate positives and negatives are gathered. For sampling positives, Chen et al. (2020) show that certain data augmentations (e.g. crops and cutouts) may be more beneficial than others (e.g. Gaussian noise and Sobel filtering) when generating anchors and positives for unsupervised contrastive learning. von Kügelgen et al. (2021) theoretically study how data augmentations help contrastive models learn core content attributes which are invariant to different observed "style changes". They propose latent variable model for self-supervised learning. Tian et al. (2020) further study what makes good views for contrastive learning. They propose "InfoMin principle", where anchors and positives should
24

---

Under review as a conference paper at ICLR 2022
share the least information necessary for the contrastive model to do well on the downstream task. For sampling negatives, Robinson et al. (2021) show that contrastive learning also benefits from using "hard" negatives, which (1) are actually different class from the anchor (which they approximate in the unsupervised setting) and (2) embed closest to the anchor under the encoder's current data representation. Both of these approaches capture the principle that if positives are always too similar to the anchor and negatives are always too different, then contrastive learning may be inefficient at learning generalizable representations of the underlying classes.
In our work, we incorporate this principle by sampling data points with the same class label but different ERM predictions predictions-presumbbly because of spurious attribute differences-ar as anchor and positive views, while sampling negatives from data points with different class labels but the same ERM prediction as the anchor. The anchors and positives are different enough that a trained ERM model predicted them differently, while the anchors and negatives are similar enough that the trained ERM model predicted them the same. Contrasting the above then allows us to exploit both "hard" positive and negative criteria for our downstream classification task. In Appendix A.3, we show that removing this ERM-guided sampling (i.e. only sampling positives and negatives based on class information), as well as trying different negative sampling procedures, leads to substantially lower worst-group accuracy with CNC.
One limitation of our current theoretical analysis regarding the alignment loss (cf. Section 3.2) is that we require knowing the group labels to compute the RHS of equation (6) (in particular, the alignment loss). An interesting question for future work is to provide better theoretical understanding of the alignment induced by CNC in the context of spurious correlations.
D.3 LEARNING INVARIANT REPRESENTATIONS
Our work is also similar in motivation to Invariant Risk Minimization (IRM) (Arjovsky et al., 2019), Predictive Group Invariance (PGI) (Ahmed et al., 2021), and other related works in domain-invariant learning (Krueger et al., 2020; Parascandolo et al., 2020; Ahuja et al., 2020; Creager et al., 2021). These methods aim to train models that learn a single invariant representation that is consistently optimal (e.g. with respect to classifying data) across different domains or environments. These environments can be thought of as data groups, and while traditionally methods such as IRM require that environment labels are known, recent approaches such as Environment Inference for Invariant Learning (EIIL) (Creager et al., 2021) and Predictive Group Invariance (PGI) (Ahmed et al., 2021) similarly aim to infer environments with initial ERM model. In EIIL, they next train a more robust model with an invariant learning objective, similarly selecting models based on the worst-group error on the validation set. However, they train this model using IRM or Group DRO with the inferred environments as group labels. PGI uses EIIL to infer environments, but trains more robust model by minimizing the KL divergence of the predicted probabilities for samples in the same class, but different groups, using the inferred environments as group labels.
D.4 REPRESENTATION ALIGNMENT IN DOMAIN GENERALIZATION AND UNSUPERVISED DOMAIN ADAPTATION
Finally, CNC's approach to improve model robustness via a model's 's learned hidden-layer represen- tations also bears similarity to some prior domain generalization (DG) and unsupervised domain adaptation (UDA) methods. We first discuss similarities and differences between these methods and CNC. We then note fundamental differences between the DG and UDA settings and our spurious correlations setting, which may also explain the poorer performance of the related methods observed in Appendix A.2.
Related methods for representation alignment. As introduced in Appendix A.2, to generalize beyond a single domain, such methods try to train model representations for samples that are aligned or invariant across domains. With domain adversarial neural networks (DANN), Ganin et al. (2016) accomplish alignment by adversarially training a model's encoder layers (the "feature extractor") to learn representations such that a separate domain classifier module cannot distinguish samples' domains from the learned representations. To preserve class information, they train a classifier module top of the feature extractor jointly with cross-entropy loss. CNC's process for aligning representations more simple. We do not rely on training separate modules with conflicting objectives to accomplish alignment; instead the supervised contrastive loss with CNC's sampling
25

---

Under review as a conference paper at ICLR 2022
procedure encourages learning representations that are both separable across classes and aligned within each class. We thus avoid additional training parameters and optimization issues associated with minimax- based adversarial training (Arjovsky & Bottou, 2017). Instead of relying the domain classifier's output, we can train single model to align representations by minimizing the cosine similarity between anchor and positive samples.
Meanwhile, Li et al. (2018) propose maximum mean discrepancy MMD adversarial autoencoder (MMD-AAE). To align representations between domains, MMD-AAE (1) trains an autoencoder, (2) uses MMD maximum applied at the bottleneck hidden-layer to match representations across domains, and (3) applies an adversarial discriminator network to match these representations with Laplace distribution (to encourage more sparse hidden representations). This matching is also not conditioned on the sample classes; an additional classifier head is applied to preserve class-specific information. CNC is also simpler than MMD-AAF, only using the normalized dot product of a single classifier's last hidden-layer representations. Via contrastive learning. CNC also critically also aims to only align representations with the same class but different ERM-inferred groups, while pushing apart samples with different classes but the same ERM-inferred groups. By paying attention to the classes, we directly encourage model to ignore group-speciing information which confused the initial ERM model but that does not discriminate between classes.
Finally, concurrent work applies contrastive learning for alignment in unsupervised domain adaptation (Wang et al., 2021). Similar to CNC, cross-domain contrastive learning (CDCL) trains an encoder to learn aligned representations. However, because the authors tackle UDA, their setup and components are different from ours. They try to align representations for samples with the same class but different known target and source domains. In their setup, domain labels are known. However, class labels are unknown for a specific "target" domain. They thus require inferring the class labels for target domain samples to set up their anchor, positive, and negative contrastive samples, introducing components that are not relevant for our setting. They infer class labels by first computing class-specific centroids for a "source" domain with class labels, and assign pseudolabels in the "target" domain based on the nearest class-centroid for each target domain sample. CDCL thus tackles fundamentally different problem. In CNC's spurious correlations setting. we do not have an obvious notion of "target" or "source" domains (instead aiming to improve the robust worst "group" performance across all unseen test samples), we do not have labels indicating whether samples are from different domains or groups, and we infer the spurious attribute values for all training samples.
Fundamental differences in tasks. All such methods proposed for domain generalization (DG) or unsupervised domain adaptation (UDA) also tackle fundamentally different problem settings from this work. First, both DG and UDA assume knowledge of training data domain labels. However in our setting, we must do the equivalent of inferring these domains. The distribution shift presented in standard DG / UDA benchmarks such as VLCS (Fang et al., 2013) 3) is also distinct from the shift encountered with our spurious correlations datasets. As discussed in Appendix A.2, the notion of a "domain" must also be suitably specified for our setting. For example, in Waterbirds all samples with the same spurious attribute could be the same domain (e.g., the "water background" domain). Alternativlly, all samples that exhibit the dominant spurious correlation could be domain (e.g.. the "waterbird, water background; landbird, land background" domain). Using DG or UDA approaches for our setting requires resolving this ambiguity, which is not present in prior DG or UDA works.
Differences with domain generalization. In DG, (tackled by MMD-AAE) we have access to multiple "source" domains, know which "group" each sample belongs to (defined by domain-class combinations), and aim to generalize to a specific unseen "target" domain not present during training. Unlike the spurious correlations presented in our evaluated datasets, class distributions within domain are also not skewed. Standard benchmarks such as Office (Sæenko et al., 2010) and VLCS (Fang et al., 2013) report much more uniform class distributions for each domain, compared to standard spurious correlations benchmarks such as Waterbirds where 95% of images in each background domain have the same class. Furthermore, in our setting we do not assume group labels or know the domain of any training sample. We also try to improve performance on the worst-group at test-time, which could belong to any domain encountered at training time.
Differences with unsupervised domain adaptation. In UDA, (tackled by DANN and CDCL) methods also assume knowledge of training sample domains or spurious attributes, whereas CNC and our other comparable methods do not. UDA methods also assume fundamentally different data setup; the training data divided into source and target domains, and only the source domain
26

---

Under review as a conference paper at ICLR 2022
has labels. The goal is to the source and target features the source labels to transfer to the specific target domain. However, in our setting we do have class labels for all samples available during training, but do not have any natural definition of source and target domains. Applying UDA methods requires additional reintepretation of this setup. Similar to differences in our problem setting with DG, we do not have training data domain labels.
E ADDITIONAL EXPERIMENTAL DETAILS
We first further describe our evaluation benchmarks in Appendix E.1. We next provide further details on how we calculate the reported metrics and the experimental hyperparameters of our main results in Appendix E.1. For all methods, following prior work (Liu et al., 2021; Sohoni et al., 2020; Nam et al., 2020; Sagawa et al., 2019; Creager et al., 2021) we report the test set worst-group and average accuracies from models selected through hyperparameter tuning for the best validation set worst-group accuracy. While different methods have different numbers of tunable hyperparameters. we try to keep the number of validation queries as close as possible while tuning for fair comparison.
E.1 DATASET DETAILS
Colored MNIST (CMNIST*). We evaluate with version of the Colored MNIST dataset proposed in Arjovsky et al. (2019). The goal is to classify MNIST digits belonging to one of 5 classes y = {(0, 1), (2, 3), (4, 5). (6, 7), (8, 9)}, and treat color as the spurious attribute. In the training data, we color Peer of each class's 's datapoints with an associated color a, and color the rest randomly. If Peurr is high, trained ERM models fail to classify digits that are not the associated color. We pick from uniformly interspersed intervals of the hsv colormap, e.g. 0 and 1 digits may be spurious correlated with the color red (# f00000) while 8 and 9 digits may be spuriously correlated with purple (# ##fff018 8). The full set of colors in class order are A = fC000,, # #85ff00, #00fff3, # 6e00ff, A #E00018} (see Fig. 2). For validation and test data, we color each datapoint randomly with a color a e A. We use the default test set from MNIST, and allocate 80%-20% of the default MNIST training set to the training and validation sets. For main results, we set Peurr = 0.995.
Waterbirds. We evaluate with the Waterbirds dataset, which was introduced as a standard spurious correlations benchmark in Sagawa et al. (2019). In this dataset, masked out images of birds from the CUB dataset (Wah et al., 2011) 1) are pasted on backgrounds from the Places dataset (Zhou et al., 2017). Bird images are labeled either as waterbirds or landbirds; background either depicts water or land. From CUB, waterbirds consist of seabirds (ablatross, auklet, cormorant, frigatebird, fulmar, gull, jaeger, kittiwake, pelican, puffin, tern) and waterfowl (gadwell, grebe, mallard, merganser, guillemot, Pacific loon). All other birds are landbirds. From Places, water backgrounds consist of ocean and natural lake classes, while land backgrounds consist of bamboo forest and broadleaf forest classes
The goal is to classify the foreground bird as y {waterbird, landbird), where there is spurious background attribute A = (water background, land background]. We use the default training, validation, and test splits (Sagawa al., 2019), where in the training data 95% of waterbirds appear with water backgrounds and 95% of landbirds appear with land backgrounds. Trained ERM models then have trouble classifying waterbirds with land backgrounds and landbirds with water backgrounds. For validation and test sets, water and land backgrounds are evenly split among landbirds and waterbirds.
CelebA. We evaluate with the CelebA spurious correlations benchmark introduced in Sagawa et al. (2019). The goal to classify celebrities' hair color y (blond, not blond), which is spuriously correlated with the celebrity's identified gender A = {male, female). We use the same training, validation, test splits as in Sagawa et al. (2019). Only 6% of blond celebrities are male; trained ERM models perform poorly this group.
WWLLD.. WILDS. We evaluate with the CivilComment-- dataset from Koh et al. (2021), derived from the Jigsaw dataset from Borkan et al. (2019). Each datapoint is a real online comment curated from the Civil Comments platform, a commenting plugin for independent news sites. For classes, each comment is labeled as either toxic not toxic. For spurious attributes, each comment is also labeled with the demographic identities (male, female, LGBTQ, Christian, Muslim, other religions, Black, White) mentioned; multiple identities may be mentioned per comment.
CivilComments-
27

---

Under review as a conference paper at ICLR 2022
The goal is to classify the comment y (toxic, not toxic). As in Koh et al. (2021), we evaluate with A = {male, female, LGBTQ, Christian, Muslim, other religions, Black, White). There are then 16 total groups corresponding to (toxic, identity) and (not toxic, identity) for each identity. Groups may overlap; a datapoint falls in a group if it mentions the identity. We use the default data splits (Koh al., 2021). In Table A.6, we list the percentage of toxic comments for each identity based on the groups. Trained ERM models in particular perform less well on the rarer toxic groups.
Table A.6: Percent of toxic comments for each identity in the CivilComment--ilD. training set.
Identity
male
female
LGBTQ
Christian
Muslim
other religions
Black
White
% toxic
14.9
13.7
26.9
9.1
22.4
15.3
31.4
28.0
E.2
IMPLEMENTATION DETAILS
E.2.1 REPORTED METRICS
Main results. For the CMNIST* Waterbirds, and CelebA data sets, we run CNC with three different seeds, and report the average worst-group accuracy over these three trials in Table 1. As we use the same baselines and comparable methods as Liu et al. (2021), we referenced their main results for the reported numbers, which did not have standard deviations or eтror bars reported. For CivilComments- WILDS, due to time and compute constraints we only reported one run. We note that CMNIST here extremely challenging, as minority groups together only make up 0.5% of the training set. This severe imbalance explains the very poor worst-group performance of ERM (as well as couple other methods that fail to sufficiently remediate issue).
Estimated mutual information. We give further details for calculating the representation metric introduced in Sec. 3. As a reminder, we report both alignment and estimated mutual information metrics to quantify how dependent model's learned representations spurious attributes, and compute both metrics on the representations Z = {fene over all test set data points Then supplement the alignment loss calculation in Sec. 3, we also estimate T(Y: Z) and (AA; Z), the mutual information between the model's data representations and the class labels and spurious attribute labels respectively.
the class labels versus the
To first estimate mutual information with Y, we first approximate p(y =) by fitting a multinomial logistic regression model over all representations Z to classify y. With the empirical class label distribution p(y), we compute:
i(Y: 2)
1
ΣΣ
ply
log log
p(y 2)) p(v)
(18)
IZ
2EZ DEY
We do the same but substitute the spurious attributes for compute i(A; 2).
E.2.2 STAGE I ERM TRAINING DETAILS
We describe the model selection criterion, architecture, and training hyperparameters for the initial ERM model in our method. To select this model, recall that first train ERM model to predict the class labels, as the model may also learn dependencies on the spurious attributes. Because we then use the model's predictions on the training data infer samples with different spurious attribute values but the same class label, we prefer an initial ERM model that better learns this spurious dependency, and importantly also does not overfit the training data. Inspired by the results in prior work (Sohoni et al., 2020; Liu et al., 2021), we then explored using either standard ERM model, one with high e-2 regularization (weight decay among these, because the validation data has both class labels and spurious attributes, we choose the model with the largest gap between worst group and average accuracy on the validation set. For fair comparison to JTT, we use the same batch size, learning rate, momentum, optimizer, default weight decay, and number of epochs as reported in Liu et al. (2021) to obtain these models. We detail the ERM architecture and hyperparameters for each dataset below:
1). or one only trained on a few number of epochs. To select
28

---

Under review as a conference paper at ICLR 2022
Colored MNIST. We use the LeNet-5 CNN architecture in the pytorch image classification tutorial. We train with SGD, few epochs E = 5, SGD, learning rate 1e-3, batch size 32, default weight decay 5e-4, and momentum 0.9.
Waterbirds. We use the torchvision implementation of ResNet-50 with pretrained weights from ImageNet as in Sagawa et al. (2019). Also as in (Sagawa et al., 2019), we train with SGD, default epochs E = 300, learning rate 1e-3, batch size 128, and momentum 0.9. However we use high weight decay 1.0.
CelebA. We also use the torchvi si ImageNet--retrriieed ResNer-50 and default hyperparam- eters from Sagawa al. (2019) but with high weight decay: we train with SGD, default epochs E = 50, learning rate Ic-4, batch size 128, momentum 0.9, and high weight decay 0.1.
implementation of BERT with pretrained weights and number of tokens capped at 300 as in Koh et al. (2021), As in Liu et al. (2021), with other hyperparameters set to their defaults (Koh et al., 2021) we tune between using the AdamW optimizer with learning rate le-5 and SGD with learning rate 1e-5, momentum 0.9, and the PyTorch ReduceLROn l lateau learning rate scheduler. Based on our criterion, we use SGD, few number of epochs E 2, learning rate le-5, batch size 16, default weight decay 1e-2, and momentum 0.9.
SooommmettsWWLDDSS We use the HuggingFace (pytorch - trransorrmeeeee
E.2.3 CONTRASTIVE BATCH SAMPLING DETAILS
We provide further details related to collecting predictions from the trained ERM models, and the number of positives and negatives that determine the contrastive batch size.
ERM model prediction. To collect trained ERM model predictions on the training data, we explored two approaches: (I) using the actual predictions, i.e. the argmax for each classifier layer output vector, and (2) clustering the representations, or the last hidden-laye outputs, and assigning a cluster-specific label to each data point in one cluster. This latter approach is inspired by Sohoni et al. (2020), and we similarly note that ERM models trained predict class labels in spuriously correlated data may learn data representations that are clusterable by spurious attribute. As a viable alternative to collecting the "actual" predictions of the trained ERM model on the training data, with classes, we can then cluster these representations into C' clusters, assign the same class label only to each data point in the same cluster, and choose the label-cluster assignment that leads to the highest accuracy on the training data. We also follow their procedure to first apply UMAP dimensionality reduction to 2 UMAP components, before clustering with K-means or GMM (Sohoni al., 2020). To choose between all approaches, we selected the procedure that lead to highest worst-group accuracy on the validation data after the second-stage of training. While this cluster-based prediction approach was chosen computationally efficient heuristic, we found that in practice it either lead to comparable or better final worst- grrup accuracy on the validation set. To better understand this, as a preliminary result we found that when visualizing the validation set predictions with the Waterbirds dataset, the cluster-based predictions captured the actual spurious attributes better than the classifier layer predictions (Fig. 10). We defer additional discussion Sohoni al. (2020) and leave further analysis to future work.
Number of positives and negatives per batch. One additional difference between our work and prior contrastive learning methods (Chen et al., 2020; Khosla et al., 2020) is that we specifically construct our contrastive batches by sampling anchors, positives, and negatives first. This different from the standard procedure of randomly dividing the training data into batches first, and then assigning the anchor, positive, and negative roles to each datapoint in given batch. As a result, we introduce the number of positives M and the number of negatives N as two hyperparameters that primarily influence the size of each contrastive batch (with number of additional anchors and negatives also following M and N with two-sided batches). To maximize the number of positive and negative comparisons, as a default we set M and N to be the maximum number of positives and negatives that fit the sampling criteria specified under Algorithm 2 that also can fit in memory. In Appendix E.2.4, for each dataset we detail the ERM prediction method and number of positives and negatives sampled in each batch.
29

---

Under review as a conference paper at ICLR 2022
Color by ERM output prediction
Color by spurious attribute
Color by ERM cluster prediction
Figure 10: UMAP visualization of ERM data representations for the Waterbirds training data. visualize the last hidden layer outputs for a trained ERM ResNet-50 model given training samples from Waterbirds, coloring by either the ERM model's "standard" predictions. the actual spurious attribute values (included here just for analysis). and predictions computed by clustering the representations as described above. Clustering- based predictions more closely align with the actual spurious attributes than the ERM model outputs.
E.2.4 STAGE 2 CONTRASTIVE MODEL TRAINING DETAILS
In this section we describe the model architectures and training hyperparameterss used for training the second model of our procedure, corresponding the reported worst-group and average test set results in Table 1. In this second stage, we train a new model with the same architecture as the initial ERM model, but now with contrastive loss and batches sampled based on the initial ERM model's predictions. We report test set worst-grous and average accuracies from models selected with hyperparameter tuning and early stopping based on the highest validation set worst-group accuracy. For all data sets, we sample contrastive batches using the clustering-bant predictions of the initial ERM model. Each batch size specified here is also direct function of the number of positives and negatives: 2M + 2N.
Colored MNIST. We train LeNet-5 CNN. For CNC, we M 32, N 32, batch size 128, temperature = 0.05, contrastive weight = 0.75, SGD optimizer, learning rate 1e-3, momentum 0.9, and weight decay le-4. We train for 3 epochs, and gradient accumulation to update model parameters every 32 batches.
Waterbirds. We train ResNer-50 CNN with pretrained ImageNet weights. For CNC, we M = 17, = 17, batch size 68, temperature - = 0.1, contrastive weight À = 0.75, SGD optimizer, learning rate le-4, momentum 0.9, weight decay 1e-3. We train for epochs, and use gradient accumulation to update model parameters every 32 batches.
CelebA. We train ResNet-50 CNN with pretrained ImageNet weights. For CNC, we use M 64, N = 64, batch size 256, temperature 7 = 0.05, contrastive weight À = 0.75, SGD optimizer, learning rate le-5, momentum 0.9, and weight decay le-1. We train for 15 epochs, and use gradient accumulation to update model parameters every 32 batches.
CivilCommeets- WILDS. We train a BERT model with pretrained weights and max number of tokens 300. For CNC, we use M 16, N = 16, batch size 64, temperature = 0.1, contrastive weight À- 0.75, AdamW optimizer, learning rate le-4, weight decay le-2, and clipped gradient norms. We train for 10 epochs, and use gradient accumulation update weights every 128 batches.
E.2.5 COMPARISON METHOD TRAINING DETAILS
As reported in the main results (Table we compare CNC with the ERM and Group DRO baselines, as well as robust training methods that do not require spurious attribute labels for the training data: CVaR DRO (Levy et al., 2020), GEORGE (Levy et al., 2020), Learning from Failure (LiF) (Levy et al., 2020), Predictive Group Invariance (PGI) (Ahmed et al., 2021), Contrastive Input Morphing (CIM) (Taghanaki et al., 2021), 1). Environment Inference for Invariant Learning (EIIL) (Creager et al., 2021), and Just Train Twice (JTT) (Liu et al., 2021). For each dataset, use the same model architecture for all methods. For the Waterbirds, CelebA, and CivilComments WILDS data sets, we report the worst-group and average accuracies reported in Liu al. (2021) for ERM, CVaR DRO,
30

---

Under review as a conference paper at ICLR 2022
LfF, and JTT. For GEORGE, report the accuracies reported in Sohoni et al. (2020). For CIM, report results from Waterbirds and CelebA from Taghanaki et al. (2021) using the CIM + variational information bottleneck implementation Alemi et al. (2016), which achieves the best worst-group performance in their results. For EIIl,, we report results from Waterbirds and CivilComments- WIItss--IDDDSS from Creager et al. (2021). For these hyperparameters, we defer to the original papers. For GDRO, we reproduce the results with the same optimal hyperparameters over three seeds. For PGI. we used our own implementation for all results, with details specified below. For Colored MNIST, we run implementations for GEORGE, CIM, EIIL. JTT, and GDRO, using code from their authors respectively. LfF and CV&R DRO are also run with code from the JTT authors. We include training details for our own implementations below:
Colored MNIST (CMNIST*). We run all methods for 100 epochs, reporting test set accuracies with early stopping. For JTT, we train with SGD, learning rate 1e-3, momentum 0.9, weight decay 5e-4, batch size 32. We use the same initial ERM model as CNC, with hyperparameters described in Appendix E.2.2. For upsampling we first tried constant factors {10, 100, 1000). We also tried resampling strategy where for all the datapoints with the same initial ERM model prediction, we upsample the incorrect points such that they equal the correct points in frequency, and found this worked the best. With Peoer 0.995, this upsamples each incorrect point by roughly 1100. We also use this approach for the results in Fig. 7. For GDRO we use the same training hyperparameters as JTT, but without the upsampling and instead set group adjustment parameter C = 0. For LfF, we use the same hyperparameters as JTT, but instead of upsampling gridsearched the q parameter E {0.1, 0.3, 0.5, 0.7, 0.9), using q 0.7. For CVaR DRO we do the same but use hyperparameter 0.1. For GEORGE we train with SGD, learning rate Ie-3, momentum 0.9, weight decay 5e-4, For CIM, we use the CIM + VIB implementation. We train with SGD, learning rate 1e-3, weight decay 5e-4, | parameter 10, and À parameter le-5. For EIIL,, for environment inference we use the same initial ERM model as CNC and JTT, and update the soft enviromment assignment distribution with Adam optimizer, learning rate le-3, and 10000 steps. Following Creager et al. (2021)'s own colored MNIST experiment, we train the second model with IRM, using learning rate 1e-2, weight decay 1c-3, penalty weight 100, and penalty annealing parameter 80.
CelebA. We also tune EIIL for CelebA. We again use the same initial ERM model as CNC, and update the soft environment assignment distribution with Adam optimizer, learning rate 1e-3, and 10000 steps. We train the second model with GDRO, using SGD, 50 epochs, learning rate le-5, batch size 128, weight decay 0.1, and group adjustment parameter 3.
PGI To compare against PGI, we tried two implementations. First, we followed the PGI algorithm to first infer environments via the same mechanism as in ElII. [2], and trained a second model with the PGI objective using standard shuffled minibatches (aiming minimize the KI. divergence for samples with the same class but different inferred environment labels per batch). However, despite ample hyperparameter tuning (trying loss weighting component À E {0.1, 0.5, 10, 100), we could not get PGI to work well (on Waterbirds, we obtained 51.0 worst-group accuracy and 79.6 2.66 average accuracy). We hypothesize this is due to the strong spurious correlations in our datasets: while Ahmed et al. (2021) only considers datasets where 20% of the training samples do not exhibit dominant correlation and fall under minority groups. Our evaluation benchmarks are more difficult due to stronger spurious correlations, e.g., in Waterbirds only 5% of samples do not exhibit the dominant correlation; similarly only 7% of training samples lie in the smallest group in CelebA
We then tried more balanced batch variation. Instead of using randomly shuffled minibatches, used the PGI environment inference labels to sample batches similarly to how CNC uses the stage I ERM model predictions to sample batches. We construct batches by specifying the same number of "anchors", "positives", and "negatives" as in CNC, and sample batches where anchors and positives samples with the same class, but different inferred environments. Anchors and negatives samples in the same inferred environment, but with different classes. We then trained second model with the PGI criterion with these modified batches.
In Section E.2.6, we include our sweeps for both the method-specific and general hyperparameters.
Comparison limitations. One limitation of our comparison is that because for each dataset we sample new contrastive batches which could repeat certain datapoints. the number of total batches per epoch changes. For example, 50 epochs training the second model in CNC does not necessarily lead to the same total number of training batches as 50 epochs training with ERM, even if they use the
31

---

Under review as a conference paper at ICLR 2022
same batch size. However, note that the numbers we compare against from Liu et al. (2021) reported with early stopping. In this sense we are comparing the best possible worst-gron group accuracies obtained by the methods, not the highest worst-group accuracy achieved within limited number of training batches. We also found that although in general the time to complete one epoch takes much longer with CNC, CNC requires fewer overall training epochs for all but the CivilComments-WII dataset to obtain the highest reported accuracy.
E.2.6 HYPERPARAMETER SWEEPS
To fairly compare with previous methods (Liu et al., 2021; Creager et al., 2021; Taghanaki et al., 2021), we use the same evaluation scheme (selecting models based worst-group validation error), and sweep over a consistent number of hyperparameters, i.e. number of validation set queries. We set this number for CNC to be a comparable number of queries that is reported in prior works. We break this down into method-specific (e.g. contrastive temperature in CNC, upweighting factor in JTT), and shared (e.g. learning rate) hyperparameter categories.
-echod-specific For CNC, we tune three method-specific hyperparameters: contrastive loss temper- ature (Eq. 3), contrastive weight (Eq. 7), and gradient accumulation steps values in Table A.7.
Table A.7: Method-speciff hyperparameters for CNC.
Hyperparameter
Dataset All
Values
Temperature (T)
{0.05, 0.1}
Contrastive Weight (A)
All
{0.5, 0.75}
CMNIST Waterbirds, CelebA
{32, 64)
Gradient Accumulation Steps
CivilComments-WIl
{32, 64, 128]
For JTT, the reported results and our CMNIST implementation are tuned over the following hyperparameters in Table A.8.
Table A.8: Method-specific hyperparameters for JTT.
Hyperparameter
Dataset
Values
Waterbirds
{40, 50, 60) {1,2}
Stage I Training Epochs
CMNIST", CelebA, CivilComments WILDS
CMNIST
{10, 100, 1000, 1100} {20, 50, 100} {4,5,
Upweighting Factor
Waterbirds, CelebA
WenlCoomeets-WILLDS
For EIII,, our CMNIST and CelebA implementations are tuned over hyperparameters reported in Table A.9. Creager et al. (2021) report that they allow up to 20 evaluations with different hyperparameters for Waterbirds and CivilComments -WI.m.. When using GDRO as the second stage model, they also report using the same hyperparameters as the GDRO bascline for Waterbirds. We do the same for our evaluation on CelebA. This amounts to primarily tuning the first stage environment inference learning rate and number of updating steps for CMNIST and CelebA, and the penalty annealing iterations and penalty weight for the IRM second stage model for CMNIST*
Table A.9: Method- specific hyperparameters for EIiL.
Hyperparameter
Dataset
Values
Environment Inference Learning Rate
CMNIST CelebA (le-1, le-2, 1e-3)
Environment Inference Update Steps
CMNIST* CelebA [10000, 20000)
IRM Penalty Weight
CMNIST
10.1, 10, 1000, 1e5)
IRM Penalty Annealing Iterations
CMNIST
(10, 50, 80)
GDRO Group Adjustment
CelebA
(0, 2, 31
32

---

Under review as a conference paper at ICLR 2022
implementation uses CIM + VIB, and is tuned over the / VIB parameter Alemi et al. (2016) and contrastive weighting parameter À for CIM in Table A.10. Taghanaki et al. (2021) report tuning over a range of values within [le-5, 1] for À on the CclebA and Waterbirds data sets.
For CIM, our CMNIST
Table A.10: Method-specinn hyperparameters for CIM.
Hyperparameter
Dataset
Values
CIM A
CMNIST
{0.01. 0.05, 0.1)
VIB B
CMNIST (le-5, le-3, le-1, 10)
For PGI, we tune À with the same environment inference parameters as used in EIIL (Table A.9). Fixing these parameters to infer environments, we tuned the À component for training the robust model across À E (0.1,0.5, 10, 100}.
Shared For all data sets, we use the same optimizer and momentum (if applicable) as reported in the JTT paper. Table A.11 contains the data-specific shared hyperparameter values tried.
Table A.11: Shared hyperparameters
CMNIST
Waterbirds
CelebA
CivilComment-WILDS
Learning Rate
[le-4, le-3, 1e-2) (le-4, 5e-4)
[le-4, le-3)
[le-5, le-4)
[lc-5, lc-4]
Weight Decay
(le-4, le-3)
(1e-2, le-1)
(le-2)
E.3 CNC COMPUTE RESOURCES AND TRAINING TIME
All experiments for CMNIST Waterbirds, and CelebA were run machine with 14 CPU cores and a single NVIDIA Tesla P100 GPU. Experiments for CivilComment--WI. were run on an Amazon EC2 instance with eight CPUs and one NVIDIA Tesla V100 GPU.
Regarding runtime, one limitation with the current implementation of CNC is its comparatively longer training time compared methods such as standard ERM. This is both a result of training an initial ERM model in the first stage, and training another model with contrastive learning in the second stage. In Table A.12 we report both how long it takes to train the initial ERM model and long it takes complete one contrastive training epoch each dataset. We observe that while in some cases training the initial ERM model negligible, especially if we employ training with only a few epochs to prevent memorization (for Colored MNIST it takes roughly two minutes to obtain sufficient initial ERM model), it takes roughly 1.5 and hours to train the high regularization initial models used for Waterbirds and CelebA. While these hurdles shared by all methods that train an initial ERM model, we find that the second stage of CNC occupies the bulk of training time. Prior work has shown that contrastive learning typically requires longer training times and converges more slowly than supervised learning (Chen et al., 2020). We also observe this in our work.
We note however that because sample batches based the ERM model's predictions, the con- trastive training duration is limited by how many datapoints the initial ERM model predicts incorrectly. In moderately sized data sets with very few datapoints in minority groups, (e.g. Waterbirds, which has roughly 4794 training points and only 56 datapoints in its smallest group). the total time it takes to train CNC on par with ERM. Additionally, other methods such as additional hard negative mining (Robinson et al., 2021) have been shown to improve the efficiency of contrastive learning, and we can incorporate these components to speed up training time as well.
Table A.12: CNC Average total training time for first and second stages of CNC
Dataset
CMNIST
Waterbirds
CelebA
CivilComments WILDS
Stage ERM train time
min.
1.5 hrs
3 hrs
3.1 hrs
Stage 2 CNC train time
1.2 hrs
1.8 hrs
32.2 hrs
37.6 hrs
33

---

Under review as a conference paper at ICLR 2022
F VISUALIZATION OF LEARNED DATA REPRESENTATIONS
As in Fig. 6, we visualize and compare the learned representations of test set samples from models trained with ERM. JTT, and CNC in Fig. 11. Compared ERM models, both JTT and CxC models learn representations that better depict dependencies on the class labels. However, especially with the Waterbirds and CelebA data sets, CNC model representations more clearly depict dependencies only on the class label, as opposed to JTT models which also show some organization by the spurious attribute still.
ERM
JTT
CNC
(a)
15.01
70
Cole1
caar Calor
14.20
Caler
4555
(b)
Landbird Waterbiid
Background Water Background
Backgrount Vater Background
Landbard Water birdl
Lard Backgroundd Wacer Background
Warer bird
(c)
Famale
Not Bland
Blend
Male
Blond
Male
Blond
Male
Figure 11: UMAP visualizations of learned representations for Colored MNIST (a), Waterbirds (b), and CelehA (c). We color data points based on the class label (left) and spurious attribute (right). Most consistently across data sets, CNC representations exhibit dependence and separability by the class label but not the spurious attribute, suggesting that they best learn features which only help classify class labels.
G ADDITIONAL GRADCAM VISUALIZATIONS
On the next two pages, we include additional GradCAM visualizations depicting saliency maps for samples from each group in the Waterbirds and CelebA data sets. Warmer colors denote higher saliency, suggesting that the model considered these pixels more important in making the final classification as measured by gradient activations. For both data sets, compare maps from models trained with ERM, the next most competitive method for worst-group accuracy JTT, and CNC. CNC models most consistently measure highest saliency with pixels directly associated with class labels and not spurious attributes.
34

---

Under review as a conference paper at ICLR 2022
G.1
WATERBIRDS
Input
ERM
JTT
CNC (Ours)
Landbird, Land background
Water background
Landbird,
Waterbird, Land background
Waterbird, Water background
Figure 12: Additional GradCAM visualizations for the Waterbirds dataset. We use GradCAM to visualize the "salient" observed features used classify images by bird type for models trained with ERM, JTT, and CNC. ERM models output higher salience for spurious background attribute pixels, sometimes almost exclusively. JTT and CNC models correct for this, with CNC better exclusively focusing on bird pixels.
35

---

Under review as a conference paper at ICLR 2022
G.2 CELEBA
visualize the "salient" observed features used to classify whether a celebrity has blond(e) hair. ERM models interesting also "ignore" the actual hair pixels in favor of other pixels, presumably associated with the spurious gender attribute. contrast, GradCAMs AMs for JTT and CNC models usually depict higher salience for regions that least include hair pixels. CNC models most consistently do SO.
Figure 13: Additional GradCAM visualizations for the CelebA dataset, For models trained with ERM. JTT, and CNC, we use GradCAM
CNC (Ours)
JTT
ERM
Input
CNC (Ous)
JTT
BRM
Input
Not Blonde
Pemale
blout
Male
Blande Vensll
Blond Male
36


Reviews:
[{"review_id": "nBtyV0Yr7Ez", "reviewer": "Reviewer_GgTx", "summary": "", "questions": "", "limitations": "", "rating": 5, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "## Strength  \n- The paper is mostly well written and easy to follow. \n- Spurious correlation avoidance without assuming any prior knowledge of spurious features is an important problem with wide impact.\n\n## Weakness   \n**Standard Deviations** are important when reporting worst group accuracy metric. For example, the smallest group in CelebA (with supervised group labels) has only around 100 examples. \nExpect to see std. dev. from at least three runs for all the experiments. \nLooks like all your numbers are from a single run, given the typical std. dev. on these datasets and metric, I cannot judge the significance of your results.\n\n**More Comparisons** needed. There are some existing contrastive regularization based methods [1, 2], perhaps several more. \nAuthors should compare and argue the merits of theirs over others both intuitively or analytically and empirically. \n[1] proposed to learn representations that minimize the divergence between predictions on examples of the same label class but different partition (group).\nIn that regard, I find this work very similar to [1] with some differences as below: \n- [1] regularizes the differences in aggregate prediction probabilities while this paper minimize per-sample differences\n- [1] looks at prediction probability differences and KL measure while this work looks at representation differences and Eucledian distance.\n- [1] uses [3] for partitioning the dataset on spurious attribute while this work only uses the ERM trained base model. \nThe differences to me look only superficial. \n\n**Ablation study** on importance of first stage ERM training is needed. The authors state that the prediction accuracy of the spurious attribute in the case of CelebA is only around 59%.\nI wonder what is the significance of ERM base model at all and what would happen if we instead simply regularize the distances for any pair of points of the same true class (this would be similar to [2]).\n\n**Sensitivity to Stage 1 prediction (Sec 5.3):** \nI do not understand why in Fig. 7 (d), we see the average accuracy also decreasing with p. \nI expect the average accuracy to remain stable or increase as the worst group accuracy deteriorates. \nBoth average and worst group accuracy decreasing could indicate optimization problems?\nAlso, can you intuitively explain why you expect CNC to be more robust than JTT to stage 1 predictions?  \nAlso in Table 1, why is the Avg. accuracy of CNC so much worse than other methods on CivilComments dataset?\n\n## Minor\n- Around expression (5), inconsistency around use of hat: $\\hat L_{align}$ and $L_{align}$.\n- Again around the same expression, stick to using either $\\hat L_{align}(f_\\theta)$ or $\\hat L_{align}(f_{enc})$. \n- The theorem looks intuitive but I could not follow the proof due to notation difficulties. \n\n## References\n1. Ahmed, F., Bengio, Y., van Seijen, H. and Courville, A., 2020, September. Systematic generalisation with group invariant predictions. In International Conference on Learning Representations.\n2. Arpit, D., Xiong, C. and Socher, R., 2019. Predicting with high correlation features. arXiv preprint arXiv:1910.00164.\n3. Creager, E., Jacobsen, J.H. and Zemel, R., 2021, July. Environment inference for invariant learning. In International Conference on Machine Learning (pp. 2189-2200). PMLR.", "summary_of_the_paper": "The paper studies training of models that are robust to spurious correlations without any supervision on spurious correlation revealing example groupings. \nThey observe that representations from an ERM model trained on such data, have strong correlation with the spurious attribute.\nTheir algorithm (CNC) is aimed at repressing spurious attribute information from the representations and was shown to be effective on standard sub-population shift datasets.\nAlso, CNC is shown to be more robust to noise in spurious attribute recovery than the existing methods. ", "summary_of_the_review": "I have novelty, significance and experiment rigor related concerns as detailed in my review. ", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "", "extra_scores": {"correctness": "3: Some of the paper’s claims have minor issues. A few statements are not well-supported, or require small changes to be made correct.", "technical_novelty_and_significance": "2: The contributions are only marginally significant or novel.", "empirical_novelty_and_significance": "2: The contributions are only marginally significant or novel."}, "extra_text": {}}, {"review_id": "frdI1yOYcLF", "reviewer": "Reviewer_FMKR", "summary": "", "questions": "", "limitations": "", "rating": 5, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "Strengths\n* This paper focuses on improving model robustness to group shifts in a practical setting where group information is not available. The proposed method achieves SOTA worst-group performance to be close to GDRO which uses the true group labels.\n* Some interesting empirical analysis are presented for relating the representation alignment with worst-group performance. \n\nWeakness\n* In general, the observation is not surprising, and the idea of aligning representation for improving model robustness is not novel. There are a lot of work with similar ideas in domain generalization/adaptation literature, e.g., [1], [2]. There’s also a recent work [3] that applies contrastive learning for doing so. A more comprehensive discussion for these related work needs to be included. \n* The assumption of Theorem 3.1 is not well explained and motivated. In particular, the assumption that “the loss function l(x; y) is 1-Lipschitz in x and bounded from above by one.” seems to be necessary and simplify the proof a lot, but does not hold for typical losses like cross-entropy for classification and MSE for regression.\n* Though the proposed contrastive method leads to improved worst-group performance, it seems to decrease the average-case performance compared to baselines. More crucially, neither part of the two-stage method is justified with sufficient motivation and empirical evidence, as detailed below:\n    * Using ERM prediction as the group label is not convincing enough, and it is not clear how it would affect the contrastive part. It could be interesting to more extensively analyze how the label prediction affects the improvement given by the contrastive method, probably using a scientific setup where the label prediction is controlled. \n    * For the contrastive part, the current empirical comparison obfuscates the advantage on its own. To decouple it from the effect of wrong group prediction, it is important to compare in the setting where group labels are available, i.e., GDRO vs GDRO + contrastive. Also, there could be a lot of choices of negative selections but only one is used without sufficient explanations, it would be great to include more explanation or compare with some other possible choices as an ablation study. \n\n\nAdditional questions & comments \n* In the last paragraph of introduction, it is claimed that “...only falling short of GDRO’s worst-group accuracy by *0.3%* absolute…”. However, in Table 1, the gaps between CNC and GDRO are 1.1%, 1.4%, 0.1%, 0.7%, respectively on each dataset, how is the 0.3% gap calculated?\n\n[1] [Domain-Adversarial Training of Neural Networks](https://arxiv.org/abs/1505.07818)\n\n[2] [Domain Generalization with Adversarial Feature Learning](https://openaccess.thecvf.com/content_cvpr_2018/papers/Li_Domain_Generalization_With_CVPR_2018_paper.pdf)\n\n[3] [Cross-domain Contrastive Learning for Unsupervised Domain Adaptation](https://arxiv.org/pdf/2106.05528.pdf)\n\n\n", "summary_of_the_paper": "This paper focuses on improving the model robustness to group shifts without prior group information and bridges the gap to those methods with access to group labels (i.e., GDRO). It identifies the relation between the worst-group performance and representation alignment both empirical and theoretically, which motivates a contrastive approach for improving representation alignment and robustness. Empirically, the proposed method demonstrates improved worst-group performance over existing baselines. ", "summary_of_the_review": "Overall, the observation of the paper is not novel and the theoretical analysis is rather weak. Though the proposed method leads to improved worst-group performance, it is not well developed and supported with sufficient empirical evidence. Thus, I recommend a ‘reject’ for the paper. \n\n\n++++++++ Post-rebuttal ++++++++\n\nI will increase my score to 5, but I still think the paper can be improved a lot before acceptance as detailed [here](https://openreview.net/forum?id=cVak2hs06z&noteId=rfOvGo4VyL9).\n", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "", "extra_scores": {"correctness": "2: Several of the paper’s claims are incorrect or not well-supported.", "technical_novelty_and_significance": "2: The contributions are only marginally significant or novel.", "empirical_novelty_and_significance": "3: The contributions are significant and somewhat new. Aspects of the contributions exist in prior work."}, "extra_text": {}}, {"review_id": "Y1u2IccxqwC", "reviewer": "Reviewer_ktqR", "summary": "", "questions": "", "limitations": "", "rating": 6, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "\nStrengths:\n- it's a good idea to explore the connection between learned representations and subgroup performance\n- they show fairly clearly that in the explored methods, better separated representations often yield better predictions\n- the method seems to perform well experimentally\n\nWeaknesses:\n- I'm not sure I totally buy the proof being that intuitively useful - in particular, due to the bound B on the weight matrix. My hesitancy is because the weight matrix and the representations are learned jointly - in fact, we could get equivalent predictions by scaling the weight matrix down and the representations up. Also, the Lipschitz and boundedness constraints on the loss functions do not really apply in any of the settings explored experimentally.\n- I get a little lost in Sec 5.2. I don't what understand the role of ERM \"predicting the sensitive attribute\" - I thought the point was for ERM to predict the label? and how do ERM's predictions of the sensitive attribute play into the CNC algorithm?\n- there are some training details buried in the appendix which seem worth discussing - for instance the clustering-based prediction from the first step ERM model seems like an unintuitive step which may be fairly important to the functioning of the method. I would like to see this discussed in the main body, possibly with an ablation study. In my experience, clustering approaches can be quite helpful for these types of problems and I would like to know a bit more about the role it plays, given that it is far from the first thing you would think of doing (which would be just using the standard linear layer)\n\nOther thoughts:\n- In Figure 3, the relationship I would really like to see is L_align vs Accuracy: this is the one that makes your point most compellingly\n- In Fig 3c, I disagree with the characterization that high worst group accuracy corresponds to a combination of high I(Y,Z) and low I(A, Z). It looks like WG accuracy is mostly (but not fully) invariant to I(A, Z) in this plot, with the level-colour sets extending horizontally (more or less) across the plot\n- Some of the notation in the proof in 3.2 is a little sloppy - in particular, y is overloaded in the definitions of L_wg and L_avg, both being used inside the scope of the expectation and outside it\n", "summary_of_the_paper": "This paper discusses a two-stage method for improving a model's subgroup robustness, first training an ERM classifier and then performing contrastive learning on the representations. They provide theoretical justification for this procedure and experimental verification of its performance.\n", "summary_of_the_review": "The paper can use some cleaning up but the idea is interesting and clearly communicted enough to be of value to the conference.", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "", "extra_scores": {"correctness": "4: All of the claims and statements are well-supported and correct.", "technical_novelty_and_significance": "4: The contributions are significant, and do not exist in prior works.", "empirical_novelty_and_significance": "4: The contributions are significant, and do not exist in prior works."}, "extra_text": {}}, {"review_id": "TCCLnzCrlpU", "reviewer": "Reviewer_U9kN", "summary": "", "questions": "", "limitations": "", "rating": 6, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "\nThis paper takes a representation focused perspective on avoiding learning spurious corrections. The main motivation (well backed by experiments on toy datasets) is this: there is a positive correlation between within-class alignment loss, and worst-group error. On its own this observation isn’t hugely surprising, and arguably overlaps with observations in prior work. The novelty of this work comes from using this observation as the inspiration for CnC, a supervised contrastive approach to re-training the ERM model to reduce the within-class alignment loss.\n\nSome positives:\n\n- The paper is well written\n- The method is easy to implement, intuitive, and seems to work pretty well.\n- In section 3 the combination of empirical observation and theoretical bound make the conclusion quite convincing. \n- The method specifically samples hard positive/negative samples. This is potentially an even more important point on the novelty of the method than is currently emphasized [see the second main question below, about SupCon as a baseline]. \n- The logic and ideas in this paper are very linear, making it easy to quickly grasp the main takeaways. \n- The worst-group performance seems to decay slightly better than JTT as the level of spurious correlation increases (Fig. 7). \n\n(For weaknesses, see the questions below).\n\n\n---\n## Questions: \n\nI have *two major questions that I am hoping to see answers to:* \n\nFirst: The motivation for CnC is centered on the class-conditional alignment loss. There is even a bound on the worst-group loss in terms of the average-group and class-conditional alignment loss. So why not replace step 2, and instead fine-tune the model using L_avg_group + L_alignment? Or even just train models from scratch with this loss. It would be good to compare to these. If CnC is simply more empirically successful than this alternative, then it would be good to see this. \n\nSecond: In a related vein to the previous question, how much is CnC buying us as compared to the usual supervised contrastive training? It would be good to see SupCon as a baseline in Table 1. This seems an important baseline, since the main idea of CnC is to pull items from the same class together in feature space, which is also done using SupCon.  The main (even only?) difference is the hard positive/negative sampling approach of CnC. \n\n\n---\n\n## Miscellaneous comments and questions:\n\nThese are just a few things I was curious about. I am not per se asking for any response from the authors, but offer them up in the spirit of constructive feedback:\n\n- What if you iterate your method? That is, CnC samples positives and negatives according the *fixed* ERM model from step 1. What if you repeat step 2 again using the new and improved model obtained from the first step 2 run? Maybe it would just immediately saturate in performance, but I am curious. \n- Is there a way to incorporate spurious attribute information into the positive and negative sampling methods if it were available? \n- Do you have a rationale as to why CnC did worse than JTT for CivilComments? I’m not bothered at all by this result, since I would never ask for across-the-board improved empirical results. But I am curious at to whether any lessons can be learned about the relative strengths and weaknesses of the two methods. I notice that CivilComments has more (8) spurious feature values than the other datasets - could this be related?\n- Perhaps consider using more divergent colors in Fig 6. The different shades appear fine on my compute screen, but are hard to distinguish on a printout (maybe my printer is just bad…). \n", "summary_of_the_paper": "This paper considers the goal of training classifiers that achieve strong worst-case performance across groups with different spurious features, without assuming access to supervision based on the spurious features. The paper proposes a two-step method, which fist trains a model with ERM, then re-trains the model using a supervised contrastive approach where positive and negative samples are selected on the basis of misclassification characteristics of the ERM model. \n\n The method addresses an important problem, and is well motivated & evaluated. In all this is a nice piece of work and I am cautiously happy to recommend its acceptance at this point. I do, however, have a couple of questions I would like to see some answers to (see below). Depending on the answers to these questions, and discussion with other reviewers, I am happy to consider raising my score. \n", "summary_of_the_review": "\n The method addresses an important problem, and is well motivated and evaluated. In all this is a well executed piece of work and I am cautiously happy to recommend its acceptance at this point. I do, however, have a couple of questions I would like to see some answers to (see above). Depending on the answers to these questions, and discussion with other reviewers, I am happy to consider raising my score. \n", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "", "extra_scores": {"correctness": "4: All of the claims and statements are well-supported and correct.", "technical_novelty_and_significance": "2: The contributions are only marginally significant or novel.", "empirical_novelty_and_significance": "3: The contributions are significant and somewhat new. Aspects of the contributions exist in prior work."}, "extra_text": {}}]

Author rebuttal:

Meta-review: The paper worked on an important problem (robustness concerning spurious correlations) and proposed a useful method (achieving SOTA worst-group performance without the true group labels). However, the motivation part is weak so that it is unclear why to go from the theoretical/empirical observations to the proposed method (more specifically the contrastive learning part). The novelty is also not very strong as argued by reviewers (the real novelty was not highlighted by the authors and thus cannot easily be appreciated by readers). It is indeed a borderline case but seems to be below the bar of acceptance and the two reviewers staying on the positive sides would not like to fight for it. Since there is still room for improvement, we hope the paper would benefit from a cycle of revisions for a re-submission and the improved version would be accepted in the near future.

By the way, what GgTx suggested is not really an out-of-scope study, as far as I understood. The authors certainly think that the paper/method has been clearly motivated. This reviewer was asking for a strong motivation, namely, what is missing or what is wrong in existing methods or the SOTA method so that we need/have to apply the proposed method? Without clarifying this point, the paper/method is partially but not fully motivated and the method may look like another alternative though it should be a better one. Instead of showing the better performance, the reviewer would like to see the conceptual advantage of the proposal by understanding what is missing/wrong in the current SOTA method. Therefore, I think this is a great question for the authors to maximize the impact of their work in the end.
Decision: Reject