Invariant Causal Mechanisms through Distribution Matching
Authors: Mathieu Chevalley
Charlotte Bunne
Andreas Krause
Stefan Bauer
Venue: ICLR 2022 Submitted (2022)
Keywords: representation learning
causality
invariance
distribution matching

Abstract: Learning representations that capture the underlying data generating process is akey problem for data efficient and robust use of neural networks. One key property for robustness which the learned representation should capture and which recently received a lot of attention is described by the notion of invariance. In this work we provide a causal perspective and new algorithm for learning invariant representations. Empirically we show that this algorithm works well on a diverse set of tasks and in particular we observe state-of-the-art performance on domain generalization, where we are able to significantly boost the score of existing models.

Under review as a conference paper at ICLR 2022
INVARIANT CAUSAL MECHANISMS THROUGH DISTRI- BUTION MATCHING
Anonymous authors Paper under double-blind review
ABSTRACT
Learning representations that capture the underlying data generating process is a key problem for data efficient and robust use of neural networks. One key property for robustness which the learned representation should capture and which recently received lot attention is described by the notion of invariance. In this work we provide a causal perspective and new algorithm for learning invariant representations. Empirically we show that this algorithm works well on a diverse set of tasks and in particular we observe state-of-the-an art performance on domain generalization, where we are able to significantly boost the score of existing models.
INTRODUCTION
Learning structured representations which capture the underlying causal mechanisms generating data of central importance for training robust machine learning models (Bengio al., 2013; Schölkopf et al., 2021). One particular structure the learned representation should capture is invariance to changes in nuisance variables. For example, we may want the representation to be invariant to sensitive attributes such as the race or gender of an individual in order to avoid discrimination or biased decision making in a downstream task (Creager et al., 2019; Locatello et al., 2019; Träuble et al., 2021).
While learning invariant representations is thus highly important for fairness applications, it also appears in seemingly unrelated tasks such domain adaptation (DA) and domain generalization (DG), where one aims to be invariant across the different domains (Muandet et al., 2013; Zemel et al., 2013; Ganin et al., 2016; Peters et al., 2016). For tasks such DA and DG invariance across domains or environments implies to being invariant to the domain index, which thus is the "sensitive attribute" in this case and typically implies change in the distribution of the data generating process. Being invariant to the domain index is thus a proxy to being invariant to latent unobserved factors that can change distribution.
Established approaches for enforcing invariance in the learned representation usually aim to learn representation whose statistical distribution is independent the sensitive attribute e-g.. by including an adversary during training (Ganin et al., 2016; Xie et al., 2017). As an adversary is essentially parametric distributional distance, other approaches minimize different distribution distances, such as maximum mean discrepancy (MMD) (Louizos et al., 2017: Li et al., 2018b), or optimal transport (OT) based distances (Shen et al., 2018: Damodaran al., 2018). To enforce independence, these methods add regularizer to the loss that consists in the pairwise distributional distance between all possible combination of the sensitive attribute, i.e., (pst(p( =|d), p(=]'d())))))))))) d' E D. As such, the complexity of the loss grows quadratically in the size of the support of the sensitive attribute, which can limit the applicability of these models when the support of D is large (Koh et al., 2021).
Despite the importance of learning invariant representations and their potential socictal impact in the medical domain or fair decision making, most established approaches are still based on heuristics and specialized for different tasks at hand. We take first steps towards a unifying framework by viewing invariance as a property of a causal process (Pearl, 2009; Peters et al., 2017) and our key contributions be summarized as follows:
We introduce a unifying causal framework for invariant representation learning, which allows us derive new algorithm enforce invariance through distribution matching.

---

Under review as a conference paper at ICLR 2022
One advantage of our algorithm is that only one distributional distance between two batches needs to be computed at each step, irrelevant of the size of the support of D. We define the notion of style variable and present some necessary and sufficient conditions under which being invariant to the domain index actually leads to invariance to the style variables. We argue that proposal naturally captures most of the existing invariant representation learning tasks and datasets.
Finally, we conduct large number of experiments across different tasks and datasets, demonstrating the versatility of our framework. We obtain competitive results on the task of learning fair representations and we are able to significantly boost the performance of existing models using our proposed algorithm for the task of DG.
INVARIANT REPRESENTATION LEARNING ACROSS TASKS
In this section, we highlight how the learning of an invariant representation is goal that (implicitly) pursued in large spectrum of machine learning tasks.
Domain Adaptation The range of techniques used in Domain Adaptation and the different as- sumptions followed are vast (see Wilson and Cook (2020) for more depth review). Thus, we here concentrate only subset of the literature. A direction that is widely followed in DA, and which the closest to our framework, is the alignment of the latent distribution of the source and target datasets. Under the covariate shift assumption, which assume that the labeling function P(Y|X) fixed, and that only P(X) varies across environments, the goal is then to learn a representation h(X) that is invariant across source and target and that remains useful learn discriminator on the source dataset. Ganin et al. (2016) uses a domain adversarial network to align the two latent spaces, whereas others uses distributional divergences directly, such as MMD) (Baktashmotlaagh et al., 2016), Wasserstein and optimal transport in general (Shen et al., 2018; Damodaran et al., 2018; Redko et al., 2017). DA under different assumptions, such as the case where both P(Y) and P(X have also been studied (Gong et al., 2016).
Domain Generalization Though very similar to DA, DG differs in one significant way: the test domain is not observed at training time. As such, is a way harder task as the test domain could exhibit arbitrary shifts in distribution, and the learned model is supposed to handle any reasonable shifts in distribution. Without any assumptions, there is little hope obtain models that actually generalizes. Nevertheless, many inductive biases and models have been proposed, which have stronger assumptions than classical empirical risk minimization (ERM) (Vapnik, 1998).
Given its similarity to DA, similar models have been proposed, and most models work for both tasks. Nevertheless, until recently (Albuquerque et al., 2019; Deng et al., 2020), theoretical justification, e.g., for minimizing the distance between pairs of latent variables coming from different domains, was missing, as results from domain adaptation assumes that the test domain is observed. Without some assumptions, there exists theoretical reasons to infer that constant distribution of the latent variables across the training domains leads to better generalization on the test domains. Indeed, many benchmarks (Gulrajani and Lopez-Paz, 2020: Koh et al., 2021) show that it is difficult to create algorithms that consistently beat ERM across different tasks. Invariant representations for DG was first proposed by Muandet et al. (2013). This idea was then extended to use other distributional distances, such as MMD (Li et al., 2018b). Adversarial (Li et al., 2018d; Deng et al., 2020; Albuquerque et al., 2019), and Optimal Transport (Zhou et al., 2020) (see Table 1). On the theoretical side, both Albuquerque et al. (2019) and Deng et al. (2020) attempt to give theoretical grounding to the use of an adversarial loss by deriving bounds similar to what exists DA.
Domain Generalization and Causal Inference Many links between causal inference and domain generalization have been made, arguing that domain generalization is inherently causal discovery task. In particular, causal inference can be seen as a form of distributional robustness (Meinshausen, 2018). In regression, one way of ensuring interventional robustness is by identifying the causal parents of Y, whose relation to is stable. This can be achieved by finding a feature representation such that the optimal classifiers Rojas-Carully et al., 2018; Arjovsky et al., 2019). Unfortunately, most of these models do not really apply to classification of structured data such images, where the classification is predominantly
approximately the same across domains (Peters et al., 2016;
2

---

Under review as a conference paper at ICLR 2022
Table 1: Review of invariance across different tasks, Note that the general loss is defined as Ei= ((x,, + X (dist(z?), = 1)))
Task
Adversarial
MMD
Wasserstein
Distunce equation
42 log outed y-N log madden
Er (a) Limnes 0(s))
L Ga(s) Mine. Galni
Domain Adaptation
(2016)
Baktashmoolagh et (2016)
Shen et al. (2015)
(2017)
Damodaran (2018)
Domain Geseenlization
Gunin et al. (2016), Albuquerque et (2019)
ct al. (20188)
Zhou et al. (2020)
Li at al. 8dse): Deng at (2020)
Fair Repeesentztion Leaming
Edwands and Stockey (2015); Xie at. al. (2017)
Louizos et all (2017)
Jiang al. (2020)
and Rodden (2019)
anti-causal and where the wanted invariance is not toward the pixels themselves but towards the unobserved generating factors. In a similar setting to ours, Seinze-Demil and Meinshausen (2021) tackles the task of image classification and propose new model. significant difference to our work is that they rely on the observation of individual instances across different views, i.e., the images are clustered by an ID.
Fair Representation Learning Fair representation learning can also be viewed as an invariant representation learning task. This task consists in learning a representation that maximizes usefulness towards predicting target variable, while minimizing information leakage of a sensitive attribute (e.g., gender, age, race). The seminal work in this field is Zemel al. (2013), which aims at learning multinomial random variable Z, with associated vectors Uk, such as the representation Z is fair. More recent work directly learns a continuous variable Z that has minimal information about the sensitive attribute, either through minimizing the MMD distance (Louizos al., 2017), through adversarial training (Edwards and Storkey, 2015; Xie et al., 2017; Roy and Boddeti, 2019), or through Wasserstein distance (Jiang et al., 2020).
3 INVARIANCE AS THE PROPERTY OF A CAUSAL PROCESS
In this section, we will first consider the assump- tions for the causal process underlying the data generating mechanism using structural causal model (SCM) type graph from Causality theory (Pearl, 2009) and following the causal view of learning disentangled representations (Suter et al., 2019), as illustrated in Figure
S
G₁
G2
Gs
G
Gi to G3 represents all the factors of variation that generate the data, i.e. there exists a (one-to-one) function such that given all the factors, X is fixed: X + (GI,..., Gk)
Y is a target value that we may want predict in downstream task and is either known (super- vised setting) or unobserved (unsupervised). D is another confounder that we want to be invariant to. be a domain index, such in DA and DG, or sensitive attribute such as in fairness. We will assume for now that does not have an effect on Y.
Figure 1: A direct acyclic graph (DAG) exhibit- ing our assumptions on the data generating pro- cess. We suppose that the data X is a function of unobserved generative factors G (e.g.. back- ground colors, brightness, noise, shape). There may exist some confounders Y and D that are parents of the generative variables. Y is the vari- able that we want to predict. want to be invariant to. Only X, D and possibly Y are observed at training time. The representa- tion variable Z is function of the data X that we create at training time.
Lastly, the generative factors G; are assumed not have any causal relations between them, and any correlation between some factors may only come from a hidden confounder. This assumption is similar to the assumptions in Suter et al. (2019). Furthermore, in this work. assume that the label and directly have an effect on the latent generating factors. In this setting, Y and D are thus independent.
the variable we
3

---

Under review as a conference paper at ICLR 2022
Given data generating framework, now give some definitions, especially the notion of style generating factors.
Definition 3.1. We call style variables the set of variables G that are children of in the DAG. We denote this set S.
Observation 3.1. X and Z are independent from D given S, they are d-separated from D by the set S in the graph.
To the best of our knowledge there is no consistent and widely accepted definition of an invariant representation, yet. Using the above framework, we propose the following definition:
Definition 3.2. We say that a representation Z is invariant a variable D if and only if D has no total causal effect on Z.
This definition of invariance is very robust since it guarantees that no intervention on the variable D can break the independence between Z and D. This is partieularly relevant in application such as fair and private representation learning, as we may not want that intervening on the distribution of sensitive variable breaks the property of fairness or privacy of representation.
The goal of invariant representation learning can then be described as creating a new variable Z = fX) such that D has no total causal effect on variable in the SCM and learning its structural equation. If we assume that our distribution follows our proposed SCM (Figure 1), then absence of total causal effect equivalent to independence, as D has no parent in the DAG. We use this assumption of D having no causal parents in Theorem 3.1.
way, we can view as adding new
Theorem 3.1. Under the assumption of the graph in Figure 1, we have that:
Z is independent from D (equivalently, D has no total causal effect on Z, or p(=ld) = p(z]d") for all d, d') + p(z]do(d= Na)) = p(z) for all Na (intervention the distribution of D).
In summary. Theorem 3.1 states that no total causal effect is equivalent to independence given the right assumptions, and that having a constant marginal distribution of 2 under different mixtures of D leads to independence. The proof is presented in Appendix B.
In the case where the full support of D observed during training, we have the guarantee that independence in training (Z; D) will hold in any test setting. However, in DG for example, observe a new value of D at test time. Having p(z]dtrasn)) = (((aderaan that p( ((]eeeet) = p(2 p(z]deraing)- Indeed, in this setting, the variable D works more like an index, where each value indicates a domain where the distribution variable D is thus a proxy to being invariant the unobserved style variables (see Definition 3.1).
does not guarantee
has changed. Invariance to the
4 AN ALGORITHM FOR INVARIANT LATENT VARIABLE DISTRIBUTIONS
Necessary Condition for Invariant Representation Learning We first start by studying whether invariance to 1 may lead to invariance (or least independence) to the style variables. For simplicity, suppose we are given two datasets drawn from two distributions P1 and p2 X, i.e., D E 21, We assume that only the style variables had their distribution changed across the two datasets.
The goal is to learn representation of X that is invariant to the style variables. We thus need to learn an encoder f E F, = = ((x)
Theorem 4.1. Independence to D is a necessary condition for the representation to be invariant to the style variables.
The proof is trivial and can be found in Appendix B. As this theorem shows, having representation z that invariant to D is at least necessary for invariance to the style variables. Unfortunately, it is in general not sufficient. It may be sufficient under some assumptions variables, but this is a direction we will not follow as it often leads to a very restrictive setting.
the distribution of the style
A variable has total causal effect on a variable if and only if: X, A. X pdo(Xe= (Xe=8z) for some random variable N₂ (Definition 6.12 in Peters et al. (2017)).
4

---

Under review as a conference paper at ICLR 2022
Sufficient conditions for Invariant Representation Learning We here present an idealistic set- ting where invariance to D is sufficient. Obviously, this setting is almost never observed in practice. nevertheless gives a sense of how difficult the task is and of what kind of direction we should follow.
Theorem 4.2. If we are given a (possibly infinite) number of domains, where each domain exhibits different possible intervention on the style variables S, then independence to D implies no total causal effect of 5 on Z.
The proof can be found in Appendix B. We here take the view that the variable D indexes an intervention, which is common view in causal inference via DG (see Section 2). It also shows that there may always be a test domain where we observe an intervention to which our representation is not invariant, especially if it changes the support of the style variables. For examples, if we want to be invariant to the brightness in an image, we can only do so to a certain extent, as being invariant to full brightness (i.e., white image) would force constant and non-informative representation. This type of question is similar to what is studied in adversarial robustness. Consequently, we need assumptions on what types of interventions we may encounter the wild. One reasonable assumption is that the full possible support of the style variables is observed during training. We then need to be invariant to any combination of possible values of the style variables. If the style variables are not observed, we cannot directly intervene on them. One possibility is thus to use the variable D as proxy to simulate interventions on the style variables.
Conjecture 4.3. Given finite number of domains, we can create new domains via mixtures of the given domains, which simulates new types of interventions on the style variables S.
The idea is that having these new created domains may facilitate identifiability of representation Z invariant to the style variables S, as in a way it gets us closer to the conditions of Theorem 4.2.
New Algorithm for Invariant Representation Learning Based on the underlying assumptions of Figure I, the equivalence proved in Theorem 3.1 and Conjecture 4.3, we present to learn a representation invariant to interventions on D. This algorithm could be useful for example when we have large number of different values of D, where enforcing an invariant p(=|d) is hard to optimize (pairwise distances between distributions). Instead, we change the distribution of D across batches (simulated intervention) and take the distribution distance between pairs of batches. It also follows Conjecture 4.3: as each time we create a batch with a different distribution of D, it equivalent to drawing a batch from a created domain, which is mixture of the initially given domains. We formulate the optimization goal as follows:
algorithm
L(Y c()), s.t. p(Z) const VNa- z=f(X)
min
We relax this constraint by taking the dual formulation and by approximating the maximum distance between two possible interventions on D by the average distance:
min ((Y,c(Z)) + A ENA.Y [dist(p(Z)do(C) Na). p(Z)do(d= N2) 2=f(x)
where dist is distance between distributions (see Appendix A for possible distances), and No. N/ are interventions on the distribution of d.
First, this algorithm gives us a new method to learn invariance when our dataset follows the assumption of Figure If the dataset indeed fulfills our assumptions, we theoretically have that the algorithm will work asymptotically. Unfortunately, these assumptions are not testable. There is thus two possible outcomes: either the optimization converges and we cannot reject that the dataset follows assumptions, or it does not converge and probably means that the causal relationships of the variables of our dataset are different than assumed.
Second, stated in Conjecture 4.3, being invariant to different distributions of D may lead to greater invariance to the style variables. This is especially useful in DG. In Section 5, we experimentally show that our algorithm is indeed viable method to learn invariance, and that it can also be more
5

---

Under review as a conference paper at ICLR 2022
favorable in settings such as DG. We present possible practical implementation of our algorithm 1 below.
Algorithm 1:
Our algorithm for invariant representation learning.
Let be the number of domains; Let n be the number of samples drawn from each class at each step; begin
Draw a batch of n samples for each domain:
B1, B2 t 0,
/ We create two batches B1 and B2 that approximate the interventions Na and N of eq. (1)
for i do
~ n(), B1, 13 - (B1,b s)), (B2, b.[s :)):
// Concatenate B1 and B2 with a slice of b
end
71, 72 - ((B1),
10
loss dist(Z1, 22);
12
return loss;
13
end
5
EMPIRICAL EVALUATION
5.1 FAIR REPRESENTATION LEARNING
In this section, we present some experiments on Fair representation learning. Here, the goal is not necessarily to obtain better results compared to other baselines. More importantly, we want to show that: (i) Fair representation learning also an invariant representation learning task, and it covered by our unifying framework; (ii) Our algorithm is applicable to wide range of tasks, as it also gives competitive results on this task; (ii) We can control the strength invariance via the hyperparameter X; (iv) Fair representation learning datasets probably also follow proposed data generation graph.
In the context of fair representation learning, the variable D we want to be invariant to here cor- responds to what is usually referred to the sensitive variable. A sensitive variable is variable that should not have an effect on the predictions of a classifier or regressor. Some examples are the sex, the race or the age of individual. If information about the sensitive variable, there is no way for model built on top of this representation the sensitive variable. Unfortunately, in most datasets, the sensitive variable
construct representation that does not contain
to base its prediction is actually predictive for the target variable, i.c., the value we are trying to predict. This introduces a trade-off between fairness and accuracy of model.
Datasets We run experiments two datasets from the UCI ML-repository (Asuncion and Newman, 2007), the Adult and German dataset. The German dataset consist predicting whether an individual has good or bad credit. while the sensitive attribute is the gender. The Adult dataset consists in predicting whether the annual income of an individual more or less than 50, 000S, and the sensitive attribute is the gender. See Table in the Appendix for summary of the datasets. We also report the size of the majority class for the sensitive and target attribute for each dataset. fair model should have sensitive accuracy that close or below the size of the majority sensitive class, while having target accuracy as high as possible.
Experiment Design To run our experiments, we reuse the code from Roy and Boddeti (2019) and add our model. We also empirically modify the default latent representation size such that it is optimizable using the MMD distance. As for the synthetic experiment, after training of the encoder, we freeze it and learn two discriminators: one for the target and one for the sensitive attribute. The target discriminators is trained for 100 epochs and the adversary discriminator for 150 epochs. We report the best achieved test accuracy. The goal of this setup is to assess how much information be extracted from the representation regarding the target and sensitive variables. For each value of A regularization, run the experiment three times, and report mean and standard deviation. We

---

Under review as a conference paper at ICLR 2022
Table 2: Comparison other existing models on the Adult dataset.
Model
Target Accuracy
Adversary Accuracy
CausIRL with MMD (ours)
85.0
69.8
MI-ARL (Xie et al., 2017)
84.4
67.7
MaxEnt-ARL (Roy and Boddeti, 2019)
84.6
65.5
LFR (Zemel et al., 2013)
82.3
67
VFAB (Louizos et al., 2017)
81.3
67
also report the best obtained model and compare it to other baselines. The goal is to show what performance we can potentially achieve with our algorithm and see how compare with existing models.
5.1.1 ADULT DATASET
The encoder is a neural network with one hidden layer of size 7, and a latent representation size of 2. It is trained for 150 epochs using the Adam optimizer (Kingma and Ba, 2015), with learning rate of 1 x 10-1 and weight decay of 5 x 10-2 The discriminators are two-hidden-layer neural networks, with hidden layers of size 64 and 32. Both optimized using Adam with learning rate of 0.001 and weights decay of 0.001. The learning rate of the discriminators is adjusted with Cosine Annealing. to 128 and test batch size 1000.
Train batch size
Results are summarized in Figure 2, as well as a comparison with other baselines in Table 2. The results are as we expected: stronger regularization leads to stronger invariance towards the sensitive attribute. We also get that there is a trade-off between target accuracy and adversary accuracy, as the sensitive attribute informative towards predicting the target. Compared other baselines, our best model performs well, as it has the best target accuracy for slightly higher adversary accuracy.
Adecnary Acars
Advenary Accens
72
33.
12-
Tags Arcesay
Tager Accenc
632
Laviii Reptbraeee
Regulammtionn
Lambea lepshmmtrs
Lambda Kepshmaakm
(a) Target Accuracy (b) Adversary Accuracy (c) Target Accuracy on (d) Adversary Accuracy the Adult dataset.
on the Adult dataset.
the German dataset.
on the German dataset.
Figure 2: Target and adversary Accuracies for the Adult and German dataset for different strength of regularization.
5.1.2 GERMAN DATASET
The encoder is neural network with hidden layers of size 15 and and latent representation size of 32. It is trained for 150 epochs using the Adam optimizer, with learning rate of x 10 and weight decay of 5 x 10-2 The discriminators are soo-hidde--llyer neural networks, with hidden layers of size 10. Both are optimized using Adam with learning rate of 0.001 and weights decay of 0.001. The learning rate of the discriminators adjusted with Cosine Annealing. Train batch size set to 64 and test batch size to 100.
Results are summarized Figure 2, as well as a comparison with other baselines in Table 3. Here, we observe that 1.0 is clear optimal value for X, as it gives the highest target accuracy and the lowest adversary accuracy. bit more surprisingly, we observe that higher regularization can give lesser invariance, which we obtain competitive results as we get the smallest adversary accuracy, even below the majority prediction, while still obtaining the second best target accuracy.
interpret form of ver-regularization Compared to other methods,
7

---

Under review as a conference paper at ICLR 2022
Table 3: Comparison to other existing models on the German dataset.
Model
Target Accuracy
Adversary Accuracy
CausIRL with MMD (ours)
80.3
67.0
MI-ARL (Xie et al., 2017)
74.4
80.2
MaxEnt-ARL (Roy and Boddeti, 2019)
86.33
72.7
LFR (Zemel et al., 2013)
72.3
80.5
VFAB (Louizos et al., 2017)
72.7
79.7
5.2 DOMAIN GENERALIZATION
Datasets For this experiments, we on seven datasets: ColoredMNIST (Arjovsky et al., 2019), RotAtedMNIST (Ghifary et al., 2015), VLCS (Fang et al., 2013), PACS (Li et al., 2017), OfficeHome (Venkateswara al., 2017), Terralncognita (Beery et al., 2018) and DomainNet (Peng et al.. 2019). In the Appendix, Table 8 shows sample images for each dataset under different domains and Table 9 presents each dataset's characteristics.
Experiment Design We run our experiments with the DomainBed (Gulrajani and Lopez- Paz, 2020) testbed, which is a recent widely used testbed for DG. We choose this setup as it allows for highly fair and unbiased comparison with other existing models. DomainBed was designed to be reproducible, to give each algorithm the same amount of hyperparameter search, and to accurately estimate the variance in performance. Three model selection methods are considered: training-doman validation (all training models are pooled and fraction of each of them is used as validaiton set), leave-one domain-out cross-validation (cross validation is performed using a different domain as validation, and the best models is retrained on all training domains) and test-domain validation set (a fraction of the test domain is used as validation set). The first two methods are closer to a realistic setting, whereas oracle validation allows improvement. Training-domain validation assumes that all training domains and the test domain follows similar distribution, as we pool all the training domains during training. On the other hand, leave-one domain-out cross-validation is closer to our assumption, as it optimizes for generalization an unseen domain that assumed follow different distribution.
evaluate whether there exists headroom for
Proposed Models We take two existing models, MMD and CORAL, based matching distribution across domains, and propose two new models, CausIRL. with MMD and with CORAL. These two new algorithm simply consist in changing how the regularization loss is computed according to proposed algorithm. i.c.. instead of taking pairwise distances across domains, we compute distances between batches that follow different domain distributions. We thus want see if this simple change in the algorithm leads to better performance, which may be due as we conjecture to greater invariance the style variables, as well as the fact that may be easier to optimize. The hyperparameter is drawn randomly in Uniiffrmm-11
5.2.1 MODEL SELECTION: LEAVE-ONE- SONE-DMAIN--UT CROSS- VALIDATION
We now look at the DG experiment results for the -ow-innn--omi-ouuu cross-validation model selection method. The results are summarized in Table 4. The result for this model selection method are the most relevant as it closely follows our assumptions on the training and test distributions. The results for the other model selection methods can be found in Appendix E.
Here, the overall performance CausIRI. with CORAL almost identical CORAL. Nevertheless, there are some differences when looking the performance individual datasets. CausIRL with CORAL overperform CORAL on PACS, TerraIncognita and DomainNet, where CORAL performs better on VLCS and OfficeHome. However should note that only the overperformance of CausIRL with CORAL over CORAL on DomainNet is statistically significant when looking at the confidence intervals of the average accuracies.
For CausIRL with MMD, we observe a significant boost in the overall performance compared to MMD. CausIRL with MMD performs hetter almost all datasets, and we also observe significant
8

---

Under review as a conference paper at ICLR 2022
Table Domain Generalization experimental results for the leave-one-domain-our cross-validation
model selection method.
Algorithm
ColoredMNIST
RotutedMNIST
VLCS
PACS
OfficeHomee
Terralncoguita
Domainneet
Avg
CausTRI, with CORAL (ours)
39.1 2.0
97.8
76.5
83.6 +
68.1 = 0.3
47.4 0.5
41.8 = 0.1
64.9
CORAL
1:
=.
76.7
82.6
683
4633
CausTRL
(ours)
47.9
MMD
36.8 1. 0.1
97.8
77.3 1
83.2 1:
60.2
16.3 1
23,4 1.5
60.7
ERM
36.7 0.1
-
83.0 77.2.1..4
63.7 0.5
414114
40.6 1.2
63.2
IRM
40.3 4.2.
07.0=02
76.34:066
81
643
4.
33.5
62.0
GromDDO
65.2
449+14
40.7
76.9
CDANN
39.1 +
97.3 =2
77.5 + 0.2
78.8 2.2
64.3 =
399
38.0 + 0.1
62.2
VREx
36.9 2 0.3
93.6 34
76.7
2: L.0
81.3
4
64. = 13
373 3.0
33.4
2 3.1
60.6
Table 5: Performance results of our proposed datasets on Camelyon17 and RxRx1 compared to other baselines.
Algorithm
Camelyon17
RxRx1
CausTRI. CORAL (ours)
29.0
CORAL
59.5 + 7.7
28.4 0.3
CausIRL with MMD (ours)
63.4 = 11.2
28.9 0.1
MMD)
28.2
ERM
70.3 + 6.4
29,9 0.4
GroupDRO
68.4 + 7.3
23.0 0.3
IRM
64.2 + 8.1
9.9 + 1.4
leap in performance on DomainNet going from 23.4% 38.9%. This shows that the inductive bias of our algorithm matches the real inductive bias of DG far more accurately.
6 REAL-WORD WORLD DOMAIN GENERALIZATION
In this section, we run experiments on more realistic distributional shifts. We use the Wilds (Koh al., 2021) benchmark and run experiments RxRx1 (Taylor et al., 2019). Camelyon17 consists in predicting whether region of tissue contains tumor tissue, while being invariant the hospitals where the sample was taken. The goal is obtain a model that generalizes across hospitals, as hospital specific artifacts of the data collection process can vary. RxRx1 consists of cell images, where the cells received some genetic treatment (as well as no treatment). The goal is to predict the genetic treatment among 1, 139 possible treatments. Here, we want to be invariant to the batch the cells come from, as it is common observation that batch effect can greatly alter the results.
datasets: Camelyon17 (Bandi al., 2018) and
We test our two proposed models, CausIRL with CORAL and with MMD on both datasets. For the RxRx1 dataset, we the same hyperparameters than for the CORAL model in the Wilds implementation. For Camelyon17, we change the number of group per batch to three and the batch size 60. The results summarized in Table 5. As for the DG experiments BomainBed before, we observe that CausIRI. with CORAL performs better than CORAL Moreover, IRu with MMD performs slightly better than CausIRL with CORAL on Camelyon17 7 and similarly RxRx1. Unfortunately, all models perform worse than simple ERM. Nevertheless, we again observe that our proposed models work competitively even realistic dataset, and that our proposed algorithm to compute the distributional distance regularization is better than how it is usually done.
7 CONCLUSION AND FUTURE WORK
In this work, we provided a causal perspective on invariant representation learning. We defined style variables in the context of our framework and developed theory on what conditions are necessary or sufficient to be invariant towards the style variables. Based these theoretic insights and the assumptions on the data generating process, we then proposed a new algorithm for enforcing invariance to style variables in the learned representations. We empirically demonstrated that algorithm is versatile as it works on a diverse set of tasks and datasets. In particular, it performs strongly in DG, where obtain state-of-the-ar performance.

---

Under review as a conference paper at ICLR 2022
8 REPRODUCIBILITY STATEMENT
Regarding the theoretical results, all results are based on the assumptions of Figure 1, and the proofs can be found in Appendix B. For the fair representation learning experiments, the architectures and training procedures are precisely described in Section 5.1, and we reused the code of Roy and Boddeti (2019) ensure a fair comparison existing models. For the DG experiments, we used two benchmarks, DomainBed (Gulrajani and Lopez-Paz, 2020) and Wilds (Koh et al., 2021), which were designed to reproducible and unbiased. The hyperparameter used can be found in the main text. Regarding the implementation of our algorithm, the pseudo-code in algorithm 1 and the python code snippets the Appendix should sufficient to accurately implement our proposed models. For all experiments, our implementation of the MMD and CORAL distance are taken from the DomainBed (Gulrajani and Lopez-Paz, 2020) code. Our code implementations are provided with all the necessary details in the corresponding sections in the appendix. For the implementation details for fair representation learning we refer to the detailed documentation of the code section D and for domain generalization refer to section E.
10

---

Under review as a conference paper at ICLR 2022
REFERENCES
I. Albuquerque, J. Monteiro, M. Darvishi, T. H. Falk, and I. Mitliagkas. Generalizing to unseen domains via distribution matching. arXiv preprint arXiv:1911.00804, 2019.
M. Arjovsky, Bottou, I. Gulrajani, and Lopez-Paz. Invariant risk minimization. arXiv preprint arXiv:1907.02893, 2019.
A. Asuncion and D. Newman. Uci machine learning repository, 2007.
M. Baktashmotlagh, M. Har, i, and M. Salzmann. caaributiio-matchiinn embedding for visual domain adaptation. Journal of Machine Learning Research, 17(108): 2016. URL http:
/ wamml..rrg/aperr.e
115 11-15-010 207 htmml.
Bandi, O. Geessink, Q. Manson, M. Van Dijk, M. Balkenhol, M. Hermsen, B. E. Bejnordi, B. Lee, K. Paeng, A. Zhong, et al. From detection of individual metastases classification of lymph node status at the patient level: the camelyon17 challenge. IEEE Transactions on Medical Imaging, 2018.
Beery, G. Van Horn, and Perona. Recognition in terra incognita. ECCV, 2018.
Y. Bengio, A. Courville, and P. Vincent. Representation learning: A review and new perspectives. IEEE transactions pattern analysis and machine intelligence, 15(8))1798-1825 2013.
E. Creager, D. Madras, J.-H. Jacobsen, M. Weis, K. Swersky, T. Pitassi, and R. Zemel. Flexibly fair representation learning by disentanglement. In International conference on machine learning. pages 1436-1445. PMLR, 2019.
B. B. Damodaran, Kellenberger, Flamary, D. Tuia, and N. Courty. Deepjdot: Deep joint distribution optimal transport for unsupervised domain adaptation. In Proceedings of the European Conference on Computer Vision (ECCV), pages 447-463, 2018.
Z. Deng, F. Ding, C. Dwork, R. Hong, G. Parmigiani, P. Patil, and P. Sur. Representation via representations: Domain generalization via adversarially learned invariant representations. arXiv preprint arXiv:2006.11478 2020.
H. Edwards and A. Storkey. Censoring representations with an adversary. arXiv preprint 10.0597 2015.
C. Fang, Y. Xu, and D. N. Rockmore. Unbiased metric learning: On the utilization of multiple datasets and web images for softening bias. ICCV, 2013.
Y. Ganin, Ustinova, Ajakan, P. Germain, H. Larochelle, F. Laviolette, M. Marchand, and V. Lempitsky. Domain-adversarial training of neural networks. The journal of machine learning research, 17(1):209-2030, 2016.
M. Ghifary, W. Bastiaan Kleijn, M. Zhang, and D. Balduzzi. Domain generalization for object recognition with multi-task autoencoders. ICCV, 2015.
M. Gong, K. Zhang. T. Liu, Tao, C. Glymour, and B. Schölkopf. Domain adaptation with conditional transferable components. In International conference on machine learning, pages 2849. PMLR, 2016.
I. Goodfellow, Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville, and Y. Bengio. Generative adversarial nets. In Z. Ghahramani, M. Welling, C. Cortes, N. D. Lawrence, and K. Q. Weinberger, editors, Advances in Neural Information Processing Systems 27, pages 2672-2680. Curran Associates, Inc., 2014. URL http: http:::/aaprrs...e nips. cc/ happpppr/////////////eeeeeeeeepe 5423 - 0e223-generativee adversarial -neteneetes. nets.pdf.
A. Gretton, K. Borgwardt, M. Rasch, B. Schölkopf, and A. Smola. A kernel method for the two- sample-problem. Advances in neural information processing systems, 19:513-520, 2006.
Gulrajani and D. Lopez-Paz. In search of lost domain generalization. arXiv preprint 4rXiv:2007.01434, 2020.
11

---

Under review as a conference paper at ICLR 2022
C. Heinze-Deml and N. Meinshausen. Conditional variance penalties and domain shift robustness. Machine Learning, (1(())303-345) 2021.
J. Hoffman, E. Tzeng, T. Park, J.-Y. Zhu, P. Isola, K. Saenko, A. A. Efros, and T. Darrell. Cycada: Cycle-consistent adversarial domain adaptation, 2017.
Z. Huang, H. Wang, E. P. Xing, and D. Huang. Self-challenging improves cross-domain generalization. In Computer Vision-ECCV 2020: 16th European Conference, Glasgow, UK, August 23-28, 2020, Proceedinggs Part II 16, pages 124-140. Springer, 2020.
R. Jiang, Pacchiano, Stepleton, H. Jiang, and S. Chiappa. Wasserstein fair classification. In Uncertainty in Artificial Intelligence, pages 862-872 PMLR, 2020.
D. Kingma and J. Ba. Adam: A method for stochastic optimization. ICLR, 2015.
W. Koh, S. Sagawa, H. Marklund, S. M. Xie, M. Zhang, A. Balsubramani, W. Hu, M. Yasunaga,
R. L. Phillips, I. Gao, T. Lee, E. David, I. Stavness, W. Guo, B. A. Earnshaw, S. Haque, Beery, J. Leskovec, A. Kundaje, E. Pierson, S. Levine, C. Finn, and P. Liang. WILDS: A benchmark of in-the-wild distribution shifts. International Conference on Machine Learning (ICML), 2021.
D. Krueger, E. Caballero, J.-H. Jacobsen, A. Zhang, Binas, D. Zhang, R. Le Priol, and A. Courville. Out-of-distribution generalization via risk extrapolation (rex). In International Conference on Machine Learning, pages 5815 15-5822.. PMLR, 2021.
D. Li, Y. Yang, Y.-Z. Song, and T. M. Hospedales. Deeper, broader and artier domain generalization. 2017.
D. Li, Y. Yang, Y.ZZ Song, and T. M. Hospedales. Learning to generalize: Meta-learning for domain generalization. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018a.
H. Li, S. J. Pan, S. Wang, and A. C. Kot. Domain generalization with adversarial feature learning. In Proceedings of the IEEE Conference on Computer Vision and Puttern Recognition, pages 5400-5409, 2018b.
Y. Li, X. Tian, M. Gong, Liu, T. Liu, K. Zhang, and D. Tao. Deep domain generalization via conditional invariant adversarial networks. In Proceedings of the European Conference on Computer Vision (ECCV), September 2018c.
Y. Li, X. Tian, M. Gong, Y. Liu, T. Liu, K. Zhang, and D. Tao. Deep domain generalization via conditional invariant adversarial networks. Proceedings of the European Conference on Computer Vision (ECCV), pages 624-639, 2018d.
Locatello, G. Abbati, T. Rainforth, Bauer, B. Schölkopf, and O. Bachem. On the fairness of disentangled representations, arXiv preprint
2019.
C. Louizos, K. Swersky, Y. Li, M. Welling, and Zemel. The variational fair autoencoder, 2017.
A. Makhzani, J. Shlens, N. Jaitly, I. Goodfellow, and B. Frey. Adversarial autoencoders. arXiv preprint arXiv: 2015.
N. Meinshausen. Causality from a distributional robustness point of view. In 2018 IEEE Data Science Workshop (DSW), pages 6-10, 2018. doi: 10.1109/DS..2018..444
K. Muandet, D. Balduzzi, and B. Schölkopf. Domain generalization via invariant feature representa- tion. In International Conference on Machine Learning, pages 10-18. PMLR, 2013.
H. Nam, H. Lee, Park, W. Yoon, and D. Yoo. Reducing domain gap by reducing style bias. 2021.
J. Pearl. Causality. Cambridge university press, 2009.
X. Peng, Q. Bai, X. Xia, Z. Huang, K. Saenko, and B. Wang. Moment matching for multi-source domain adaptation. In Proceedings of the IEEE International Conference on Computer Vision, pages 1406-1415, 2019.
12

---

Under review as a conference paper at ICLR 2022
J. Peters, P. Bühlmann, and N. Meinshausen. Causal inference by using invariant prediction: iden- tification and confidence intervals. Journal of the Royal Statistical Society. Series (Staristical Methodology), pages 947-1012, 2016.
Peters, D. Janzing, and B. Schölkopf. Elements of causal inference: foundations and learning algorithms. The MIT Press, 2017.
G. Peyré and M. Cuturi. Computational optimal transport. Foundations and Trends in Machine Learning, 1::55-6077, 2019.
I. Redko, A. Habrard, and M. Sebban. Theoretical analysis of domain adaptation with optimal transport. In Joint European Conference Machine Learning and Knowledge Discovery in Databases, pages 737-753. Springer, 2017.
M. Rojas-Carulla, B. Schölkopf, R. Turner, and J. Peters. Invariant models for causal transfer learning. The Journal of Machine Learning Research, 19(1):1309 -342, 2018.
C. Roy and V. N. Boddeti. Mitigating information leakage in image representations: maximum entropy approach. 2019.
S. Sagawa, P. W. Koh, T. B. Hashimoto, and Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. arXiv preprint arXiv:1911.08731, 2019.
B. Schölkopf, F. Locatello, Bauer, N. R. Ke, N. Kalchbrenner, A. Goyal, and Y. Bengio. Toward causal representation learning. Proceedings of the IEEE, 109(5):612-634 634444,, 2021.
J. Shen, Y. Qu, W. Zhang, and Y. Yu. Wasserstein distance guided representation learning for domain adaptation. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
B. Sun and K. Saenko. Deep coral: Correlation alignment for deep domain adaptation. In European conference on computer vision, pages 443 450. Springer, 2016.
R. Suter, D. Miladinovic, B. Schölkopf, and Bauer. Robustly disentangled causal mechanisms: Validating deep representations for interventional robustness. In International Conference Machine Learning, pages 6056-6065. PMLR, 2019.
J. Taylor, B. Earnshaw, B. Mabey, M. Victors, and J. Yosinski. Rxrxl: An image set for cellular morphological variation across many experimental batches. In International Conference on Learning Representations (ICLR), 2019.
F. Träuble, E. Creager, N. Kilbertus, F. Locatello, A. Dittadi, A. Goyal, B. Schölkopf, and S. Bauer. On disentangled representations learned from correlated data. International Conference on Machine Learning, pages 10401-10412. PMLR, 2021.
V. Vapnik. Statistical learning theory wiley. New York, 1998.
H. Venkateswara, J. Eusebio, S. Chakraborty, and S. Panchanathan. Deep hashing network for unsupervised domain adaptation. CVPR, 2017.
G. Wilson and D. J. Cook. A survey of unsupervised deep domain adaptation. ACM Transactions on Intelligent Systems and Technology (TIST), 11(5):1-46. 2020.
Q. Xie, Z. Dai, Y. Du, F. Hovy, and G. Neubig, Controllable invariance through adversarial feature learning. arXiv preprint arXiv: /705. /22, 2017.
S. Yan, H. Song, N. Li, L. Zou, and L. Ren. Improve unsupervised domain adaptation with mixup training, arXiv preprint arXiv:2001.00677 2020.
R. Zemel, Y. Wu, K. Swersky, T. Pitassi, and C. Dwork. Learning fair representations. In S. Dasgupta and D. McAllester, editors, Proceedings the the 30th International Conference on Machine Learning, volume 28 of Proceedings of Machine Learning Research, pages 325-333 Atlanta, Georgia, USA, 17-19 Jun 2013. PMLR. URL http::ppp. http://etccceccccee//////o mlr, press vv28/ 2emel13. html.
/
13

---

Under review as a conference paper at ICLR 2022
M. M. Zhang, H. Marklund, N. Dhawan, A. Gupta, S. Levine, and C. Finn. Adaptive risk minimization: A meta-learning approach for tackling group shift. 2020.
F. Zhou, Z. Jiang, C. Shui, B. Wang, and B. Chaib-draa. Domain generalization with optimal transport and metric learning, arXiv preprint arXiv:2007.10573, 2020.
14

---

Under review as a conference paper at ICLR 2022
A BACKGROUND
In this chapter, we review some necessary theoretical background that is used for our theoretical results, new proposed method as well previous works. We review the main elements of Causality theory, which the central theoretical basis used to model the problems we study and to design new methods and algorithms. We also review some distributional distances used in this work, our main goal is to study invariant representation learning via invariant latent variable distribution.
A.1 CAUSALITY
Causality essentially is the study of cause and effects, which goes beyond the study of statistical associations from observational data. This allows to reason about the notion of interventions, such as a treatment in medicine. The expected effect of an intervention is general not equivalent to statistical conditioning, which calls for more profound understating of the data generating process that goes beyond correlations between variables. We here focus on Pearl's view of causality Pearl (2009), which mainly relies DAGs.
DAG allows to represent the relations between variables, where each variable is represented by a node in the graph. Consequently, we can interpret directed edges between nodes as the existence of causal effect from the parent node (the cause) on the child node (the effect).
Let G (V, E') be DAG, and P be distribution. We say that (G, P) is causal DAG model if for any C V, we have:
p(xv)do(Xw =) = II p(as|epae)[In =xww) VEV(W
where Pa, are the parents of node in graph G, I is the indicator function and do(Xw = x(w) denotes the intervention the variables Xw. As DAG model is that the distribution factorizes according to the parents in the associated graph G.
above, one of the properties of a causal
A.1.1 STRUCTURAL CAUSAL MODELS
SCM can seen as more expressive version of a causal DAG model. Formally, an SCM consists of collection S of d structural assignments, one per variable:
Xy (Xpo,
where Xpa; E X\ and N1 to Na are called the noise variables (Definition 6.2 of Peters et al. (2017)). The noise variables are assumed to be jointly independent.
For causal DAG models, defined intervention by (dX(X]do[XW> = xww)) (sometimes also written as doo(X==xw) (Xv)), where the value of some variables are set to constant value. With SCMs, we can give a more precise and general definition of interventions. An intervention now consists in replacing a subset of the collection of structural assignments by new functions. intervention can thus consist in replacing variable by constant, a new random variable even by changing the function and its arguments (i.e., its parents). The new distribution over the variables entailed by the new intervened SCM is denoted by pdo(Xx= (xxxxxXx.x... et al. (2017) for more details).
(see Definition 6,8 of Peters
With this definition, important notion is the notion of Total Causal Effect.
now equipped to reason about interventions, causes and effects. One
Definition A.I. (Definition 6. in Peters al. (2017)) We say that a variable has total causal effect on a variable & and only if:
X, ML. X₁. in pdo(Xx= No)
for random variable Ñe-
15

---

Under review as a conference paper at ICLR 2022
A total causal effect between variable X₁ and X; may only exist if there is directed path from to in the DAG associated to our SCM. On the other hand, there may no total causal effect between two variable even though there exists directed path between them in the graph.
A.2 DISTRIBUTIONAL. DISTANCES
The main goal of this work to study how invariance can be enforced by regularizing different latent spaces have the same distribution. To this end, we thus need differentiable distance divergence between distributions that can be minimized during training. We here present the most commonly used distances in the literature.
A.2.1 ADVERSARIAL
Adversarial training was first introduced in Goodfellow et al. (2014) as new method for Generative modeling. Based on game theory, it can intuitively be described as a two player game, where each player is parameterized by neural network. The Generator is function that maps its input distribution to an output distribution. We call it the generated distribution and denote it by Pg- On the other hand, Discriminator tries to distinguish between samples coming from the target dataset and samples produced by the Generator. At convergence, the Generator produces data that is distributed similarly to the target distribution, and thus it becomes impossible for the Discriminator distinguish samples.
Formally, the objective of the two-player minimax game reads:
min max VDD G) Exxepateexx) [log D(x)] Ex-pa [log D(G()))) D
where z is the input, x comes from the target distributions, and the Discriminator D should output 1 when input is samples from the target, and otherwise. the Discriminator is optimal for a given G. Equation 2 can be rewritten to show that the Generator actually minimizes the Jensen-Shannon divergence (JSD) between the generated and target distribution.
1 JSD (PII)) - D (p(
+0)) + + DKL. (
where DKL is the Kullback-Leibles (KLd) divergence. It also can be shown that if both networks have sufficient capacity, and if the Discriminator is trained to optimality after each optimization step of the Generator, then the distribution of the Generator converges to the target distribution.
Adversarial training can thus be seen as a proxy distributional distance, which corresponds to the JSD convergence. This concept of adversarial training has been extended to be used as regularizer for latent spaces. can for example be used to enforce a prior distribution on the latent space Makhzani al. (2015). It can also be used enforce is often justified as wanting two latent spaces to seem indistinguishable for an adversary, which is supposed force the encoder discard what is not constant across the input distribution. We argue that adversarial training is theoretically equivalent to minimizing any distributional divergence, and that only their optimization properties differentiate them. We will also later clarify the intuition of trying to discard the idiosyncratic in favor of the universal, and what it actually corresponds to when we look the data generation process given dataset.
latent spaces have the same distribution. Its use
A.2.2 MAXIMUM MEAN DISCREPANCY
MMD Gretton et al. (2006) is distance based empirical samples from two distributions, based on the distance between the means of the two sets of samples mapped into a reproducing kernel Hilbert space (RKHS). Let (X) and {X') Q. Then, we have:
16

---

Under review as a conference paper at ICLR 2022
MMD(X,X) =
Σ (xx)
n Σ
n1
n¹
x2'
2
k(a B.)
+
k( 2/)
k(r +f)
n f1=1
n
f,==1
where ((:-)) the associated kernel. One commonly used kernel the Gaussian kernel k(x, x²) e-AAli-=' I|a Asymptotically, for a universal kernel such as the Gaussian kernel, M M D(X, X') = 0 and only if Q. Minimizing the MMD distance during training can thus be used to align two distributions.
A.2.3 OPTIMAL TRANSPORT
OT has recently gained traction in machine learning research. particularly interesting as it defines multiple distances between distributions.
We present the main formulations of the OT problem and some distances following the notations of Peyré and Cuturi (2019). We concentrate distances defined discrete distributions.
Originally, OT can be described as the problem of transporting the mass from set of points (ZI....,IIx] Jn to set of destination points {.i...., 1m } that have finite capacities. Furthermore, the cost of transporting from a point to another is fixed by a cost matrix. There is obviously a natural analogy to logistics and planning. The OT problem thus is to fulfill this mass transport while minimizing the cost. To recast this as a distance between distribution, the mass of the source points is now described by histogram
(#: Σ, a; = 1) and the destination capacities an histogram { Σ, b, 1}. The cost matrix is C e = where Ci describe the cost of transport from r; to yy. The Kantorovich formulation of this problem is:
Lc min (C,T) (.TT)=Ecup CigTis TEU(a.b)
4
where
U(a, : [T eaxm
T1,, - a, a =b}
(4)
Ti, describes how much mass flows from z; to fj- The constrain imposes that all the mass leaves and that b is filled. Given the cost matrix, we hence can compute the divergence between two distributions, and this divergence elegantly comes with an exact description (the coupling matrix T) of how to go from the first configuration to the other. Furthermore, if v4s Vi E X lie in the same metric space with distance d and the cost matrix satisfies C.,, = d' (2,, yj) for some p 2 1, then:
(a, b) = Lc b)'/
(5)
is a distance, called the p- D-Wasserstein distance. This distance has had a large range of applications, notably for problems related to invariant representation learning (see Section 2).
B PROOFS OF THEOREMS
Theorem 3.1. Under the assumption of the graph in Figure 1, we have that:
7 is independent from D (equivalently, D has total causal effect Z, or p(=ld) p(=ld') for all
d, d') + p(z]do(d = Na)) = p(z) for all Na (intervention on the distribution of D).
Proof. = As z is descendant of d, the mechanism p(2ld) is invariant to the distribution of d.
p poldd=Na) (2) = dold=NN)) d')ddd = - (2ld") = =p(z) / Na(d')ad
=p(2)
17

---

Under review as a conference paper at ICLR 2022
Asp(2) is constant for all distribution of d, then it is also constant for deterministic distributions,
Le 62.
p(z) = f (( =
This holds for all values d, which implics that (2; D) O.
Theorem 4.1. Independence D is necessary condition for the representation be invariant to the style variables.
Proof.
p(2/d= = 1) - p(zld=2) = - / p(z)5, 2)p(s(dd 2)]ds
f p(=1s))D(S)d= p(Sid = 2)
p(z) / [M(s)== - - p(Sid= = 2)
Theorem 4.2. If we are given a (possibly infinite) number of domains, where each domain exhibits a different possible intervention on the style variables S, then independence to D implies no total causal effect of S on Z.
Proof. From the definition of total causal effect, let's suppose by contradiction that there exists an intervention S such that pdo(S=N.) p(z). Let d denote the domain that correspond this intervention. We then have a value of D such that p(=|d) A p(=), which a contradiction to being independent to D.
C SYNTHETIC EXPERIMENT
We here implement a simple synthetic experiment to verify that our algorithm effectively enforces invariance to D in a setting that exactly follows our assumptions. We also simplify the setting by considering that we directly observe the generative factors.
D
G1
G2
G3
Figure 3: Causal DAG associated to our synthetic distribution.
The distribution is generated by the following set of structural equations:
Y Ngj
D+ Nai
G Y +NG;
G2 + 2. Y +2. D + No,;
Gg + Nasi
where Ny and Na (er(0.5), NG, ~O 1). We draw the associated causal DAG in Figure 3. To create dataset, we draw 1000 samples from our synthetic distribution and use 200 them as test samples.
18

---

Under review as a conference paper at ICLR 2022
Table 6: Results of predictive accuracy for (Target Accuracy) and D (Adversary Accuracy) for different strength of regularization on our synthetic dataset.
Regularization
0.0
0.1
0.5
1.0
5.0
10.0
Target Accuracy
86.0 + 0.2
86.2
0.5
86.8 + 0.1
86.7 + 0.3
52.0
3.2
54.2 +
Adversary Accuracy
71.8 = 0.8
63.8 + 0.9
63.5 + 1.2
60.5 + 0.2
59.8 = 0.4
51.0 + 0.0
We then learn a representation that invariant D and that is predictive towards using our proposed loss. As distributional distance, we use the MMD loss with Gaussian kernel. The architecture of the encoder a neural network with one hidden layer of size 10 and a representation size of 5. The hidden layer is followed by batch normalization and ReLU activation. We use batch size 64 and train with the Adam optimizer (Kingma and Ba, 2015) for 200 epochs, with learning rate of 0.001 and weight decay of 10-5
After training of the encoder, we freeze it and train two one layer linear discriminators: one to predict Y and one predict D. For each discriminators, experiment three times for each value of lambda regularization, The results summarized in Table 6 and Figure 4.
report the best achieved test accuracy. We run this
{0.0, 0.1, 0.5, 1.0, 5.0, 10.0).
As expected, we can observe a strong correlation between the strength of regularization and the strength of invariance. We achieved perfect invariance with À = 10.0, where the adversary accuracy is 50%, but target accuracy is only 54.2%. This is expected: as and D are strongly correlated, D in the representation also reduces the predictive power of the representa-
removing information tion. There thus is trade-off between performance and invariance, that can be controlled via the value of A. Finally, this experiment confirms that our proposed algorithm a viable new method to learn invariance.
70
Accuracy
Accuracy
65
60
60
55
Target Accuracy
Adversary Accuracy
50
50
100
10
10
10
Lambda Regularization
Lambda Regularization
Figure 4: Graphical visualization of results on the synthetic dataset. The values here the same
than in Table 6.
D FAIR REPRESENTATION LEARNING EXPERIMENT SUPPLEMENTS
Compute Resources We run the experiements NVIDIA GEFORCE RTX 2080 TI GPUs.
Implementation Here is the implementation our model, which a class that we added to the code2 of Roy and Boddeti (2019) the train. py py file:
class CausIRL MMD:
def init initiinteee (self, data,
Crain_loader=None,
test_loader=None,,
19

---

Under review as a conference paper at ICLR 2022
total_epoch=200,
alpha=0.1,
epsilon=0.1,
use_cuda=False,
resume=ralse,
ekpt_filemamm=None,
resume_fileeram-NNone,,
privacy_Flag=Irue,
p
print_innterral_itnnnnt0011
print_iinterva_ttest-11 ::
# data info
self.data data
self.train_loader train_loader
self.test_loader test_loader
self.n_sensitiiv__lles sel.
self.n_targt__clas self dalf.data.o. saaf.aatt..ntaaret..llssss
models
self.adv_ned = data.
self.target_net data. target_neteett self.ddscrimmnator.mmm = data discmmiinaoor...ee
# optimizer
self.optimizer = data. Rata.optimizer
data dis.ddirrmmmttttoooppiimeeee
self.advvopptimzzer aata.adv_optimme
self self.targge_optiiill zer data. taaa.target_optimizee
def my_cdist (x1, x2)
xl_norm = x1. (2) sum (dim--1, keepdim-True)
x2_norm x2. x2. (2) sum (dim=-1, keepdim=True)
res torch. addmm (x2 www.nnom.trrasspmo (-2, -1),
x1,
x2. transsse (-2, -1), alpha=-2, add_ (x1_norm)
return res (tl.cllmmmiinneeeeeeeeeeeeeeee
def gaussian_kernet (x, y, gamma [0.001, 0.01, 0.1, 1, 10, 100, 1000])
my_cdist (x, y)
torch zeros_like (D)
for g in gamma:
exp (D.mul (-g)))
return K
def mmd (x, y)
Kxx gaussian_kerne (x, x) mean ()
Kyy manssian_kerne (y, y) .maan
Kxy gaussian_kernel (x, y) mean ()
return Kxx Kyy 2 Kxy
# loss
self.kl_loss = nn. mn.ivvivosss
melf.croos_entrroy__uc nn. mm.Crosstnrropy.sss
self.entropy_loss EntropyLoss () self.nll_loss NLLLOSSS
20

---

Under review as a conference paper at ICLR 2022
self. mww...mee..... loss nn nn.MSELoss ()
self.mnd wwwdmmndoosss = mnd
# filename
self. sel.f.log_file_ne
lolllol_lll___eee ckpt_ pept_filenamee"__ -oo.--__ooo__--- loo txt
ckpt ckpt_filenane,
filename+ "_ad____dd____eaeaeeeeea txt"
selffttarget_logffllleeesss
ckpt_filenan
"_target_log.txt
hbfs:cchcckoont_fileee.ee = ckpt_filename
sel__.cv__chcckpointt_iilee filename eakp__filenamet__ee __tt_cppt"" se sel...arrgescceeexoittf_ffeeee
ckpt_filename ckptget.ckpt!
# algorithm and visualization parameters
self.alpha torch. ([alpha+1.0),
self.resume - resume
self.epoch = 0
self.gamma param 0.01
self.plot_intervall = 10
sslf_print_innterva_.ttte
self.pzint_inttervaa_ecee = print_inteeval_crrin
self.use_cuda use_
self.privacy_flag privacy_flag
so...porivec_oottionn privacy_option
local variables
self.uniform =
/ (self. ttw..
wtr.heee.oooooceeeeeeeec..cc lal torch zeros (0, dtype=torch.
selffsensstivv__laeel===
htw_:teeeeeleeelleeeeeeebee torch. oor (0, dtype=torch..ong)
sall.semssttiiee_llbe_ooeoettt torch. (0,
selffcaata.__eenstttioec_llsss
self.catte._ttarget_cllass torch Fatp:aaoooaatttttoooooooaaaaaaa (0,
oel_.rargge:_abeeloonetct::
= torch 0, 0)
self. self..npptts.requires_gaaa = False
self.batchhunnifomm torch Faat (0, wel.fdata.no saa..ddetennssesstiiveee.eess
sel self.epsilon = torch.tensor ((pssilo)) float ()
if resume:
assert os. os.path. w.t..iissiiz isdir (' checkpoint'), TBzoor..oo.ccekkkiinn..dattttrrr if pelf.use_ cuda:
checkpoint torch. load (os. . (' checkpoiitt''' resume_files (
else:
checkpoint torch. Load (os.path. join checkpoint/ resume (ilemmme___lmmm map lap_location=labbee storage, loc: storage)
self.net checkpoint ['net']
self.best_acc 0 # ch ('acc'') self.stare salf.start_epoch self.total_epoch total_epoch
# checkpoint [' e'occh'
self.
for param in heaaarrequiiessaaaa = True
()
else:
self.ne = data.net
self.best_an 0
self.total_epoch total_epoch
if self. colf.use_cudar
21

---

Under review as a conference paper at ICLR 2022
self. net self.net.cuda
self. self.discrrminattt..eee net self. selff.disermminattr_ne.... ()
self.adv_nett self. self.adv_net.cudde
self.target_net sel...targeeeeeeeecoommmm cuda ()
hww.::ttm.m..aaaaaa.... self.net
.m..aaaaaaallllllssl...ee.., device_ids=
cudnn.benchmark True
- self. .ud
self.target_label
self.sensitiie__abeel
selff:ennsitiie__abbee_eeentttt = stt.eeeeeetttiiiieeeeeeeoooooooa cuda ()
self:target_labeLLonhhct-
= ( cuda
self.alpha = staeemm=sel.....mm welf.batch..ccccec weattchhuniffrm.com cuda
self.batch_unifozme
cuda
self.best_loss = 1e16
self.advybest_aco
self.targee_best_ecc
self.t_losses, self.t_topl, self. dfff.d_losses, self. colf.d_topl
AverageMeter(() AverageMeter (), AverageMeter() (), AverageMeter ()
self.e_losses, self.1osses = AverageMeter (), AverageMeter ()
self.t_top5, self.d_top5 AverageMeter (), AverageMeter ()
self.adv_lossee,, self.adv_topl. ael
self.entropy_Losee AverageMeter(),
AverageMeter(), AverageMeter (
self.target_loses, self.target_ AverageMeter() AverageMeter AverageMeter(). AverageMeter ()
self. self.target_topss self mal..ttargt_eetrpy..
def perform_epoch (self, epoch, test test_ Flag==FseeF
if test_flag:
self.net.eval()
selffddisermminatoz.nntttt ()
self.target_met.evae
loader = self.test_loades
string "Test"
print_interval = self selff.crint.inteervateess
data_size (en
else:
self.net. train)
self.discn wwff.ddisrrmmmnnttoreee.tt.tt
loader self.train_loadet
string "Train"
data_size = len seif.priit__ntteevalttaee
print_inge erint_interval self
iteration =
self.t_lossed reset ()
self.e_losses..
reset ()
lelf.d_losses.reeet
22

---

Under review as a conference paper at ICLR 2022
self. reset ()
self.d_topl. reset ()
sels.t_top5.reset
rest
self.enttroyy_losess..ee
()
for batch_idx, (inputs, target_label, sensitive_label in enumerate (loader)
batch_size
sipets.
iteration +=
hen...nptt..rrsreennniiss.ssiii (ippo cipput)))
oeg. ()
cop__ttarget_laaell
{
tachh.usspeeeeeeaaat..sssttsaaas 1), 1)
tarch..unsquaaeeeeaaa..rraggeee. 1), 1)
eat.fhatcccunnmfommmeeeeeeaaaaad size, ttt..ttt..essttieeeeee.caaee
: (sell/ saaitrann_enssttveeeeeeeee claas))
selffbaatcch.mfffomsssctttettttd
torchh..nsueeeeeellllfsssssstsss 1), 0) self..pttmmizee.errooo..
2, e_prob self (self. (sel.
target_outputs, - t_prob = self. telff.target_ett(cc (z)
t_loss torch. (at_hhannntnnnmssllllllllsss ott.r//ooonnoto...o.oooooooooooo 16 ent torch.tensox (0)
)
loss torch.
if self. seif.privacy_flag:
#d_outputs, _ d_prob = seif.discrlmihttrr_eee (2)
#entropy -ew.=sseeeeeffeeeee..e entoyyeotro (d_prob)
first = None
second None
for i in
ind self. label i
2_ = z [[ind]
slice random. randint (0, len (z_))
if first is None:
first 2_l:slica
second [_slice:
else:
first torch. ((first, ?_[:slice]), 0) second = torch. cat (second, ?_[slice:]), 0)
if len (first) > 1 and len (second) 1:
s loss
(first, second)
loss = t loss + self.alpha-s__os.
else:
23

---

Under review as a conference paper at ICLR 2022
loss t loss
if not test flag: update weights
self self.target_opt:mmieee ze.zzro_gradd loss.
self.optimizerrsteppp self.targee_optinnnee...cc
measure accuracy and record loss for learner
t_precl (ccuracy(t_proo) data, telf.target_labell. data)
t_prec5 = eccuracy(t_prro..... patb..ataaaaa self walf.ttrrge_label..dom .data,
topk=
batch_size)
oet.rcac.oossepppppeeeeeoooaaaaa batch_size)
pet.__eceeerppddeeeeedd.odddddde batch_size)
sel.:__copl..ppateettppreeell__ batch_size) )
sel:::_oos_.ppdaeeeppprrrilii batch_size) zate
oelf.cattropy_Lossss.pppeeee (s_loss .aaassddta.... item(), batch_size)
if seif.privacy_flag:
if not test_flag:
self
douupuus, _ a_prob self self.disscrminator..nm (z detach ())
dloss = self.nll_loss (torch. (a_probtle-1)))
self.
if not test_flacy
self hnttsrrimmntttro.p..iiieeer.r
self sel.:ddisccimnntoooo.iiieeeeerr.
d_precl (cuuracyaa_prooooo..
self.eensitive_laaee
d_prec5 = accuracyla_prob.dat.. self..ensstive_labellc.om
copk=(int
self self.d_loases (d_osss
batch_size)
uep [d_prec1 batch_size) self self.d_top5.updatee prec [0], batch_size)
if iteration print_interval
0:
print (sttrin + '_Echh: [0) [(1)
[3:
(4:
[5:22
LT [_T_Pre::_66:.2f)_.1
(B: [_.Prec:_ ___Prec5:_11:::2]..._
(ormat epoch, batch idx, data_size, float (self. f
float [lottsseef..__oosssss.ooo float float ilott/eell....oop..vvv.ttelll ()), float
flo avg),
float (eele float (self avg. float (oo.
else:
24

---

Under review as a conference paper at ICLR 2022
if iteration print_interve 0: print (string + "_Epoch: (1b)o::a1
- (3:2:_
LT Pre::
(5:
format
epoch, batch_idx, data_size,
float float att.
float
))),
float tlg.
self.t_top1 avy, return self.d_top5.avg, self sal..entrroy_loseeee self.d_topl.avv,
avg, self.d_losses..
def train(self):
self.logger = Logger pos.path. ( checkpoint/'' self.log_file file_name), title=
self.logger.set
'Train-loss', "Tss-LLoss"
'Train-Acc.', 'Train-Acc5.'s 'Test, Acc.' Ace.',,
'Test, Acc5.'
'D-Train_Loss 'D-Test_Loss',
DD-Train Aecain_Acco', 'D-Train
'D-Test.Acc.', "Dc5est_Acc5.
'D-Train-Entropy', ID-Test-antropy'']
for epoch in range print (' \nEpochh $ epoch)
self.total
train_loss, train_acc, train_acc5, d_train_loss, d_train_ace, d_train_acco, d_train_entrrop self.perfom_eeoct epoch,,, Faag_e
with torch.no_grant
test_loss, test_ace, test_acc5, d d_test_loss, d_test_ace, d_test_acc5, d_test_entropy self self.perfommepoch (epoch=epoch, test_flag=True)
htt.::/tiiiiiiiaaaaarrrrrrroooao paraa_ [0] ['ir]], float (train lo: float (teat_loss),
float float (train_acc5),
flaat float (test_acc5),
float (oszai__tt) float (d__tes___ccss) float (d_train__iac float (d_train_accce) float (d_test_aco)
float (d_test_accã),
float (d_train_entropy)
float (d_testtentrrog))
it is optimum only when reach the end of the game by optimization any other value e.g., current discriminator feedback is con-optimal if (epoch + 1) 10: print ( (aving...') # Save checkpoint. state =
'net': self.net.modee if self.use_cne else self.net 'state_dict's self. sel.f.et..tate_.dic.. (), 'ace': test_ace, 'epoch'; epoch,
25

---

Under review as a conference paper at ICLR 2022
1 'optimizer': self.optinizerrsttte...dd.
if not os us.path.isdiz checkooint() (hechppt os.mkdir checcpointttt
torch. (state, /aleee,"cchee 'checkpoint/' +
self. self.chhccpoint__ffl filennmme 'cckpt')
self.best_acc test_acc
self.best_loss = test_lose loss
self. self.logger.closee
print ("Done")
def aertomm_epoh_addeerrryylllla. epoch, feat__flaaa
if test_flag self.adv_net.eval @val_
loader self.test_loade
str = "Test"
print_interval self, prlffprint_ineerraltteet else:
aelf.adv_net.traiin
loader = self.train_loade
str "Train"
print_interval ceff.prrnt_inteeee train
self.net.eval() iteration = 0
self.adv_iosses reset
( self..ev_ttop5rreset((
sel.f.entroyy_lossss.eeees reset ()
for batch_idx, (inputs, target_label, sensitive_label) in enumerate (loader)
batch_size inputs.size (0)
iteration +=
if self.data. name 'mnist':
inputs = torch. (inputs, 1) floflloll ()
) http:pppcsssiileele.ooocoooooooo cop_:))_oopp____ppppp (inputs)
with torch corch.no_grad()
outputs, 2, self net (self.
d __uuuuuss, prob self adv adv_net (2.detach )))
less = wew..cross croscrrrsseeettoyylossssss (d__o (d_outputs,
with torch
entropy_loss ssef self.entropyyloos (prob)
if not test_flag;
self d_loss balowasbbckkwar() self helff.adv_ogtimmzzr..ss
d_prec accuracy (prob. data, self, sellstsnstivee_laall..aa
d_prec = accuracy (prob. data, topk= (int (np.min ([5, self.n_sensinne selfii_eessitiiee_ccsss]]
26

---

Under review as a conference paper at ICLR 2022
self.adv_lossen update ad__los_____ dat.aattteaaeeeeddd (), batch size)
self.adv__tol..uddtt (d [d_precl[[]] batch_size)
aelf.adv_tooS..pddaee (d prec5 [0], batch_size)
(ent oo data. item (), batch_size)
if iteration 8 print_iitentttt - 0:
print (str [
LT [4:
_T5_Pree:_
__Bntropy:_(6::3f]. format
epoch, batch_idx,
float float (stels..av
float (sseef.accv.oooollrr.ttttt ()),
float (sa1e.ssddv_ttop5..rgg
float (loo
return aols..ad__ossss.avggg self.adv_topl...
self self.adv_top5.avg, self.enttopy_ooses..ar
def train_adveessarysseff, model__filenmme=Nonn,, total_epoch=100)
self.adv_iogger = Logger ("n
celf.acv__ioo_filee_mmeee) title="Problem'
self.adv_ioger.set__tte (R' 'Train-Loss', 'Test-Loss' Aco.'s 'Train_Acc5.', Test_Acc.', 'Test_Acc5.',
Bntrooy 'Itst__ntropp'')
@olff.ddy_bettaacc 0
scheduler = neAneell fn f.avoo.iaie T_max-total_epoch, eta_min=le-7)
if model_filenamt is not None:
checkpoint torch. load (os
(os. path.join (' c'chekkoint/'', model filename)
self.net = checkpoint (' ['net'] self.net.evall ()
for epoch in range (total_epoch)
print (' \/Epochhh_sdd & epoch)
scheduler.stepll
train_loss, train_ace, train_acc5, train_entrroy
test_flag=Fales
with torch.no_grad())
test_loss, test_ace, test_acc5, test_entropy oel.:peefoommeeocccc.eeeeeeeerre (pppceeeho, test (ast_flag=True)
ad selffadt__ooger.ppedd((leeeeee
['1rr))) ['Ir(),
float (train_loss). float (test_loss), float (train_acc),
float (train_acc5), fleat (test_acc), float (test_acc5), float (train_entropp),, float (test_ (test__ntrrooy)]
Save checkpoint.
if test_acc self adv adv_best_accs print ('aaving..))
state =
if use_cua else state 'state_dict's stdctttt (), 'ace': test_ace, 'epoch'; epoch,
'net':
27

---

Under review as a conference paper at ICLR 2022
'optimizer': self sel..acd..ootiimlee.ttta.ee..ddd ()
if not os us.path.isdiz checkpoint')
os.mkdir checckoointt))
torch. (state, 'checkpoint/' + sel aelf..adt_chectpointtt
self.acvy_estt_cc test_acc
self.adv_iogeer.clog
print ("Adversary_Dene..
def perfor (self, epoch, test_flag=False) if test_flag:
loader self self.test_loade
str = "Test"
print_interval self.print.inntervalteees
else:
self cearrget_netttraiiie
loader = self.train_ieaet
str "Train"
print_interval
aarint_intervll_taaae
self.net.eva
iteration 0
gell.ttaget_losss.rrees
telf.taarget_toplrrestt
sels.targge_topS.rreet
sel2.taagge_eettrpy_osseeessss
()
for batch_idx, (inputs, target_label, sensitive_label) in enumerate (loader)
satch_size inputs.size (0)
iteration +-
if self.data name 'mnist':
inputs = torch. unsquezes (erreezeeinnutt (inputs, 1) float ()
self oe cop.. copy_ (inputs)
[eeer otgp:paaaalllllaeooooooooootttrr self.sensitive_labeeee wtt.senssttee_lllbblreeeeeee... sensitivee_label.siee[[]
with torch.no_grade.
outputs, 2, self (self.
d d_outputs, prob self wwl.ftarget_si..e. (z. detach ())
d loss = self
loss (d_outuuts, self. self.target_lapa
with torch to
entropy_loss -self wellf.entenn seelf.eetropy_looo (prob)
if not test_flag:
telf.taaget_ootimmios zerogggrrd
d d_loss.back backward self.ttarget_optimiie....c step
d_prect (probb
self. self..aarge__laell.dde
precs = accuracy (prob.data self.target_label.ddtt
topk (int mmp.min self
targttttrett_eseeee self.,_tarre_class)),,,
los.aadd.dss......ttteeee. (), batch_size)
telf. update (d (d_prec1 batch_size:
28

---

Under review as a conference paper at ICLR 2022
self. wtw..areee_.tss.uuutteeeee...
batch_size)
dat.a item item (), batch_sized
if iteration & print_interval = 0:
Frint(ste) (0
LT [L__Los::[(:::f]]:
LT [4:
_T5_Prec:_ [_
format
epoch, batch_idx, len (1oader),
float float (ootdesslltttgettossssssssvo
float [loaateeel..trrre..oolllva....t ()),
float (1oo float [looaf/eee..aareee...rrrooosssss ))
return tare wel.ggptp..g...................
sels.target_tops.ary. htt.::/g..eaa...a.eee...ooooooee
def Exain_target wwwel_ fieee=fiiennme total_ toral_epoch=100)=
self.targe: tele.targe:_Looge:: (aapprrrssssat..ooonnoooooooooo
sell. title=/Problmm'
self.target_logger Sengerrse__namms[[1 'Train-loss',
'Test-Loss', 'ccain 'Train_Acc5.', 'Test_Ace,', 'Test_Acc5.',
"Train,Entropy, "Test,
self wwr.get_eeett__cceee
scheduler = CosinennnealingiR htt.aannenettl.....arreeopppiaan
T_max=total_ eta_min=le-7,
if model_filenan is not None:
assert os.
'Error:_no
checkpoint torch loach (os.
(os. path. join join
c'heckpoint/', model filename)
self.net = (' self.net.evall ()
for epoch in range (total_epoch)
print (' \/Epochhh_sd & epoch)
scheduler.step
train_loss, train_acc, train_acc5, train_entropy (epoch=epoch, test_flag=Fales
with torch.no_gradd.
test_loss, test_ace, test_acc5, test_entropy
oel.:perroon...eoeottaaarrrreeee fla fest_flag=True)
self. https///..........o.ooooooooaoor
[0] ['Ir'],
float (ttrin_accc)) fleat (test_acc),
float (test_acc5), float (train_entropy), float (test_entroppy
if test_acc self targgt_beet__cccc print (' ('vving...)) # Save checkpoint. state =
'net': telf.target_net.mom
if self. self.use_cuda else self. salf.target_net.
'state_dicts self.target_nnet httpt_eetttttteeeeeeeeee ())
(ace'; test_ace,
29

---

Under review as a conference paper at ICLR 2022
Table Datasets used in our DG experiments, with sample images for each of them. This table is taken from Gulrajani and Lopez-Paz (2020).
Dataset
Domains
+00%
+50%
-90%
Colored MNIST
3
3
3
(degres of correlation ferwens color (afe!)
0º
15
30
459
60
75
Rotated MNIST
9
9
9
O
Caltech10l
LabelMc
SUINOP
VOC2007
VLCS
Sketch
PACS
Art
Clipart
Product
Photo
Office-Home
Terra Incognita
(comerd invation
Clipart
Infographic
Paiming
Dewk
DomainNet
epoch' epoch,
optimizer' selff.target_optiiieer.ccc wtw.:iiieeee.tttteeiieeeeeeeeeee ()
if not os te.path.isdii (' checkpoint');
os ns.mkdir(( checkpoint')
torch. (state, 'checkpoint/' + self.target. ttt.gettcchckoointtt..c. filfffiaeee
delf..targe_best__ee
test_acc
self, self.target. ttarget_logger... close ()
print Saraagee_Done""
Table 7: Main characteristies of the datasets used in our fair representation learning experiments.
Dataset
Support of D
Target Variable
Dataset Size
Input Size
Majority Sensitive
Majority Target
Adult
[ malc, female
Income > 50, 000$
45, 222
14
67%
75%
German
male, female
Good or bad credit
1, 1,000
20
69%
71%
E DG SUPPLEMENTS
Compute Resources We the 10, 560 jobs NVIDIA GEFORCE RTX 2080 TI GPUs as well as NVIDIA TITAN RTX GPUs for the more resource intensive jobs.
Baseline models
We compare algorithms the following existing algorithms:
30

---

Under review as a conference paper at ICLR 2022
Table 9: Description of the datasets used in our DG experiments
Dutaset Name
Number of Sumples
Image Dimensions
Number Clases
CokeedMNNST (Agjoskky
(0.1, (13.0.9)
cXil
28)
Rocate/MNiST 2015)
et 2013)
(Caltech00I, LabelMe. SUND9 VOC2007:
phutus, sketches)
OtficHHome Nenkateswara all..220 2017)
clipar,, product real)
Teralnaggoia (Reery 2018)
[1.180,
DomainNei (Peng et 2019)
(clipurt, infograph, paintig, quickdrow, real, sketch)
$30,575
(242
Empirical Risk Minimization (ERM, Vapnik (1998)), where the of errors is minimized across domains.
Group Distributionally Robust Optimization (DRO, Sagawa et al. (2019)), where low performing domains are giving an increasing weight during training.
Inter-domain Mixup (Mixup, Yan et (2020)).
Meta-Learning for Domain Generalization (MLDG, Li al. (2018a)).
Algorithms based on matching the latent distribution across domains:
Doomain-Aveessaa Neural Networks (DANN, Ganin et al. (2016)), where the distri- butional distance is adversarial network.
Class-conditional DANN (C-DANN, Li et al. (2018d)), which is variant of DANN matching the class conditional distributions across domains.
CORAL Sun and Saenko (2016), which aligns the mean and covariance of latent distributions.
MMD Li et al. (2018b), which uses the MMD distance.
Invariant Risk Minimization (IRM Arjovsky et al. (2019)), which looks for a representation whose optimal linear classifier on top of the representation matches across domains.
Style Agnostic Networks (SagNet, Nam al. (2021)), which tries to reduce style bias of CNNs.
Adaptive Risk Minimization (ARM, Zhang al. (2020)), which is based on meta-learning.
Variance Risk Extrapolation (vREx, Krueger et al. (2021)), where they enforce the training risk to similar across domains.
Representation Self-Challenging (RSC, Huang et al. (2020)).
Implementation penalty from this:
To be more concrete, we change the code that computes the distributional distance
for i in range (nmb): for j in range (i + 1, nmb):
penalty += self. dist loss (features [i], features [i])
if nmb 1: penalty /= (nmb * (nmb 1) / 2)
to this:
31

---

Under review as a conference paper at ICLR 2022
first None
second = None
for i in range (nmb):
slice random. randint (0, len (features (i]))
if first is None: first features [i] [:slice]
second features i] [slice:]
else:
first torch. cat (first, features [:slicce]) 0)
second torch. cat ((second, features [i] [slice:]), 0)
penalty self self.dist_ile (first, second)
Here is the concrete full class of our CausIRL with MMD model:
class MMM (ERM):
def
(self, input_shape, num_classes, dumadin, hparams)
(input_shape, nun_classes, num_domains, super (CausIRL MMD, self) hparams)
self.kernel_tyy = "gaussian"
def my_cdist (self, x1, x2):
x1_norm x1 pow (2) sum (dim=-1, keepdim=True)
x2 norm x2. (2) sum (dim=-1, seepdim-True)
res torch. addmm (x2 _e2_norm.ten tt__nommmtraapssseeeee.e.... (-2, -1),
x1,
x2 transpoee (-2, -1), alpha=-2) add (x1_norm)
return res. res.clamp_ming (1e-30)
def Kqussian_Kernel(oe
x, y, gamma= 1ommma=00.000 (0.001, 0.01, 0.1, 1, 10, 100, 1000]):
D self. self.my_cdist (x, y)
K = borch.zeros_like.
for in ganma:
a.ddd (torch, exp mD. (-g))
return
def mmd (self, x, y):
Exx self self.gand wal.f.aussiii ancssinn_keeee kernerl (x, x) mean ()
Kyy self.gaussian kerneel (y, y) mean ()
Kxy self self.gaussian beeassinnnkeeelllee (x, mean ()
return Kxx + Kyy
Xxy
def update (self, minibatches, unlabeled-Noree> objective =
penalty 0
nmb = len (minibatches)
features = fellf.featurizer/ (xi) for xi, in minibatches]
classifs [self. classifisriier (fi) for fi in features]
targets [yi for _ yi in minibatches]
first None second None
32

---

Under review as a conference paper at ICLR 2022
Table 10: DG experimental results for the training-domain validation selection method.
Algorithm
ColoredMNIST
RotatedMNNIST
VLCS
PACS
OfficeHome
Terralncognita
DomainnNt
CORAL
51.3
76.8
86.2
68.7
476.
41.5
CaUSTRI, with MMD (ours)
51.6 D.1
97.
77.5 0.4
84.0 0.8
65.7 0.6
4633 0.9
40.3 0.2
66.2
MMD
51.5 +22
9
77.5 + 0.9
84.6 + 0.5
6633 = 0.1
422
23.4 + 9.5
63.3
$1.5
71.5
6633
46.1
40.9 0.1
78.5
GroupDRO
52.1 1:
98.0
76.7
84.4 4:
66.0 =
43.2 =
33.3 4: 0.2
64.8
Mixup
12.1
98.0 0.1
77.4 1: 0.6
B1.6 11.6100 0.6
68.1 1 0.3
47.9 1.9
39.2 1 0.1
06.7
MLDG
51.110.1
97.9 0.0
77.2
84.9
668 1
47.7 0.9
11211.111
66.7
CDANN
77.5
82.6
MTL
514
979=00
71.200.4
84.6 0.
04
45.6 1.2
40.6 0.1
66.2
SagNet
0.0
900
77.8 0.5
8..3
0..1
48.6 1.0
40.3 0.1
67.2
ARM
0.
-.1
77.6 0.3
85.1 0.4
618
61
15.
35.5
VREx
0.8101
31.7
97.6 0.1
77.1
852
63.
38.9
66.1
for in range (nmb):
objective += corrsss_etrtoyyeeeteee (classifsi [i] + 1e-16, targets [i])
slice random. randint random.randint (0, len (featurrss
if first is None:
first features [i] [:slice]
second = features [1] [slice:]
else:
first = torch. cat (ffirst, features [:slice]), 0)
second torch. cat (second, features [i] [slice:]), 0)
if len (first) > 1 and len (second) 1:
penalty torch. (self. mmd (first, second)
else:
penalty torch.tensor(0) (0)
objective nmb
self.optimizer. zero_grad
(objective + (self, h.ff.hpprmms [' mmdd_aamma +penalty)) .backward ()
if torch. tensor (penalty): penalty penalty.itent
return ('loss' objective i))m(), 'penalty's penalty)
E.0.1 MODEL SELECTION: TRAINING-DOMAII VALIDATION SET
We present here the results of our DG experiments for the waining-domann validation model selection method. Result are summarized Table 10. For CausIRL with CORAL, the overall performance is slightly below vanilla CORAL CausIRL with CORAL especially underperforms CORAL the PACS dataset. On the other hand, CausIRL with CORAL performs better than CORAL on Net.inNet. For CausIRL with MMD, the overall performance is significantly better than MMD. This overperformance is mainly driven by the results on Terralncognita and DomainNet, where for the latter observe leap accuracy from 23.4% 40.3%.
E. MODEL SELECTION: LEAVE-ONE-DOMAIIN-O CROSS- VALIDATANN
We here present the complete results for the leave-one-domain-o cross- coss-validation model selection method in Table 11.
33

---

Under review as a conference paper at ICLR 2022
Table 11: DG experimental results for the leave-one-domain-ouu cross-validation model selection method.
Algorithm
ColoredMNIST
RotatedMNIST
VLCS
PACS
OfficeHomee
Terralncoguita
Domainnett
Avg
CausTRI, with CORAL (ours)
39.1 2.0
97.8
76.5
83.6 #
68.1 = 0.3
47.4 0.5
41.8 0.1
64.9
CORAL
1:
=.
76.1
68.3 6.3=022
46.3
41.1
MMD
36.8 0.1
97.8 0.1
77.3 1:
83.2 1:
60.2
16.5
23,4 1.5.
60.7
ERM
36.7 0.1
97.7 0.0
77.2 0.1
83.0 0.7
63.7 0.5
114 1.4
40.6 1 0.2
63.2
IRM
40.3 1 4.2
47.0 0.2
76.3 0034:000
81,5 0.8
64.3 1.5
41.2
33.5 4:
62.0
GroupDRO
0.1
0.2
449
+.0
Mixup
77.7
MLDG
36.7 : 0.2
97.6=00
77.20099
82.9 L.7
66.1 0.5
4.2
41.0 0.2
64.0
DANN
40.7 2.3
97
76.9 0.4
8100 L.
649 12
44.4 1.
38.2 0.2
63.4
CDANN
39.1
07
77.5 0.2
78.8 2.2
61.3
19.932
38,0 0.1
62.2
SagNer
36.5
940
47.
40.2
ARM
36.8 0.0
98.1 0.1
76.6
0.2
044=02
426
35.2 0.1
62.2
VREx
36.9 0.3
93.6 34
76.7 =
81.3 0.9
649 13
373 3.0
33.4 3.1
60.6
RSC
36.5
0..
77.5
826
63
4.
38,9
Table 12: DG experimental results for the test-domain validation set model selection method.
Algorithm
ColoredMNIST
RotatedMNIST
VLCS
PACS
OfficeHomee
Terralncognita
DomainnNt
Avg
CausTRL with CORAL (ours)
58.4 0.3
98.000]
78.2110011
87.6.1 0.1
67.7 =
5344 0:41104
42.1 1 0.1
69.4
52.8 0.0
CausTRI.
(omrs)
78.1
MMD
63.3 +
98.0 0.1
71.9 +
87.2 +
66.2
$2.0 =
23.5 + 9.4
66.9
ERM
57.8 + 0.2
97.8 0.1
77.6 + 0.3
86.7 + 0.3
66.4 0.5
$3.0 0.3
41.3 0.1
68.7
IRM
67.7
97.5
76.9
84.5
63.0
50.5
28.0 5.1
GroupDRO
Misup
58.4
98.0 0.1
78.1
86.8
68.0
54.1000
39.5
69.0
MLDG
$8.2 1: 0.4
97.8 28
77.5 0.1
86.8 0.4
66.6 0.3
$2.0::0.1
416.10..11
68.7
DANN
57.00 1.0
V79=001
79.7 +.5
85.2 +
65.1 088
506-+-06
38.3+
67.7
CDANN
+0
070=000
79.9
0.2
77.7
SagNet
58.2
-7
77.6
86.4
675
52.5
40.8 0.2
68.7
ARM
63.2 0.7
98.1-0.1
77,8
85.8
618 0.1
5.22.055
36.0
0.2
68.1
VREx
67.0 1:
0.
78.1 0.2
87.2
65.7 0.3
5.4
30.1 1.3
68.2
E.1.1
MODEL SELECTION: TEST-DOMAIN VALIDATION SET (ORACLE)
Finally, we here look at the DG experiment results for the test-domain validation set model selection. The results summarized in Table 12. This setting less realistic we have access to test samples during training, but is still useful as it shows the best possible model for each algorithm. It allows us evaluate whether there is headroom for improvement for each algorithm and to see which algorithm has the inductive bias that more closely fit the task.
For both CausIRL with CORAL and CausIRL with MMD, observe better overall performance compared to their vanilla counterparts. We even have that CausIRL with CORAL is the best overall performing algorithm among the evaluated algorithms. Once again, we observe large difference in performance on DomainNet between MMD and CausIRL with MMD, going from an average accuracy of 23.5% to 40.6%. We also again have that CausIRL with CORAL is the best algorithm for DomainNet compared to all the other algorithms, which explains why we perform well on this dataset.
34


Reviews:
[{"review_id": "kdW1ebK2K0B", "reviewer": "Reviewer_PYVV", "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": "For the causal analysis part, authors propose a causal graph, which is a slight modification of the causal generative process proposed by Suter et al.(2019). Authors claimed “our proposal naturally captures most of the existing invariant representation learning tasks and datasets”, but I did not find much content showing how this causal graph could do so. Recent works have proposed different causal graphs for similar tasks (DG, fairness, etc.) and each has certain reasoning about the causal graph. Note that causal graph is untestable from data, so I keep neutral on this part. \n\nThe rest of the analysis, e.g., theorems, is based on the proposed causal graph, which is somewhat straightforward. Theorem 4.2 is misleading: a number of domains are firstly given but the statements do not specify what the are the domains. Indeed, after checking the proof, it really means all the possible domains or interventions. Then this is a trivial result according to the definition. \n\nConjecture 4.3 is not sufficiently motivating for the algorithm. Recall group DRO. The minimax problem is defined wrt the mixture of availability domains or distributions, but the optimum can be achieved by only considering the finite available domains, so there is no need to consider the mixture into optimization. Similarly, if the given domains satisfy the so called independence constraint, then any mixture does and vice versa. Thus, in theory, there is no need to consider the mixture processing in the algorithm. Please correct me I am wrong here.\n\nExperiments show some improvement, but not very strong; see,e.g., the DG tasks. But that is OK from my side.\n\n", "summary_of_the_paper": "This paper considers a causal framework for invariant representation learning, with some analysis about the invariance and independences based on the proposed causal graph. An algorithm is then proposed based on the above analysis and empirical result validates the performance of the proposed algorithm. The paper is well written.", "summary_of_the_review": "Overall, the theoretical part (analysis, foundation for the algorithm) is weak. Given that the empirical results are not very strong, I cannot recommend an acceptance. ", "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": "3: The contributions are significant and somewhat new. Aspects of the contributions exist in prior work."}, "extra_text": {}}, {"review_id": "XP6PMfN-JaD", "reviewer": "Reviewer_sMkT", "summary": "", "questions": "", "limitations": "", "rating": 1, "confidence": 5, "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": "- There are several fundamental misconceptions in this paper. \n    -  Invariance is a property of causality that has been well established.\n        - The invariance literature is in fact motivated and established through the causal graphs. \n        - See [1] for a survey. For a textbook treatment, see chapter 2 of [2].\n    -  Causal and Anti-causal\n        - Factor models are different from causal models. Figure 1 is not a causal graph. It is a graphical model. A causal graph reflects the true data generating process in the world. \"Background color\" is not a variable in the world. \n        - If I were to interpret figure 1 charitably, it is plausible that it actually means a human's perceiving process. However, that argument was not made in the paper.\n        - The difference between how the world works and how humans perceive is the central debate between causal and anti-causal. It is not whether the task is image classification or not. The arguments such as the work like IRM is only about causal but not anti-causal are plainly wrong.\n- The algorithm is reframing the IRM algorithm. The theorems are all tautological\n    - Theorem 3.1 is just a conditional independent statement.\n    - Theorem 4.1 and theorem 4.2 are circular statements. Invariance is defined (in def 3.2) with respect to total causal effect & conditional independence.  \n    - Conjecture 4.3 is factually correct. Those mixture environments are just environments/domains induced by soft intervention. It's also the setting of IRM. However, there is no argument for why that would increase OOD performance.\n    - the algorithm in eq 1 is just reframing eq 1 in IRM.\n\n- Writing \n    - The authors did not introduce many concepts that are essential to their theoretical analysis. Examples include the do notation and the causal graph. The total causal effect is critical to the results, but it's only briefly introduced in the footnote.\n\n- references\n    - [1] \n@article{scholkopf2021toward,\n  title={Toward causal representation learning},\n  author={Sch{\\\"o}lkopf, Bernhard and Locatello, Francesco and Bauer, Stefan and Ke, Nan Rosemary and Kalchbrenner, Nal and Goyal, Anirudh and Bengio, Yoshua},\n  journal={Proceedings of the IEEE},\n  volume={109},\n  number={5},\n  pages={612--634},\n  year={2021},\n  publisher={IEEE}\n}\n  -  [2]\n@book{peters2017elements,\n  title={Elements of causal inference: foundations and learning algorithms},\n  author={Peters, Jonas and Janzing, Dominik and Sch{\\\"o}lkopf, Bernhard},\n  year={2017},\n  publisher={The MIT Press}\n}\n\n   -  IRM \n@article{arjovsky2019invariant,\n  title={Invariant risk minimization},\n  author={Arjovsky, Martin and Bottou, L{\\'e}on and Gulrajani, Ishaan and Lopez-Paz, David},\n  journal={arXiv preprint arXiv:1907.02893},\n  year={2019}\n}", "summary_of_the_paper": "- The paper claims to provide a unifying causal framework for invariance-based algorithms.\n- It uses the graphical model in figure 1 to derive some conditions for achieving invariance.\n- It also develops a new algorithm for invariance-based representation learning. The idea is based on conjecture 4.3, which hypothesizes that one can create new domains using mixtures of existing ones.\n", "summary_of_the_review": "The paper has several fundamental issues, including a misunderstanding of the existing work.\nNotably, the algorithm proposed in this paper is very similar to the algorithm in IRM.\n", "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": "1: The contributions are neither significant nor novel.", "empirical_novelty_and_significance": "1: The contributions are neither significant nor novel."}, "extra_text": {}}, {"review_id": "S1ftz2dFo2H", "reviewer": "Reviewer_H74w", "summary": "", "questions": "", "limitations": "", "rating": 3, "confidence": 3, "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": "The paper is well-written and easy to read. The proposed algorithm is pretty straightforward. \nI am however not sure if the proposed algorithm would be successful in learning invariant representations. As a toy example, imagine two datasets from different domains with only two features: x1 and x2. Now let’s say the distribution of x1 is the same for both datasets but not for x2. In other words, x2 is the style variable that should be eliminated from the learned representation. Now if we sample from these two datasets and create two mixed datasets (following the proposed algorithm) we would have two datasets with almost identical distributions (likely multi-modal). I can’t see how minimizing the distance between the distributions of these two mixed datasets would eliminate the style variable.\n", "summary_of_the_paper": "This work provides a causal perspective and new algorithm for learning invariant representations from multiple domain datasets. This work introduces the notion of style variables and shows theoretically that being invariant to the domain index actually leads to invariance to the style variables. The extensive experiments demonstrate the usefulness of the proposed algorithm in various tasks.\n", "summary_of_the_review": "The toy example described above shows that the proposed algorithm should not be able to learn invariant representations. There is however the possibility that I have misunderstood parts of the paper. I’m willing to increase my score should the authors address the above-mentioned issue.\n", "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": {}}]

Author rebuttal:

Meta-review: The reviewers are in consensus. I recommend that the authors take their recommendations into consideration in revising their manuscript.
Decision: Reject