C ONFOUNDER I DENTIFICATION - FREE C AUSAL V ISUAL F EATURE L EARNING
Anonymous authors
Paper under double-blind review
A BSTRACT
Confounders in deep learning are in general detrimental to model’s generalization where they infiltrate feature representations.
Therefore, learning causal features that are free of interference from confounders is important.
Most previous causal learning-based approaches employ back-door criterion to mitigate the adverse effect of certain specific confounders, which require the explicit identification of confounders.
However, in real scenarios, confounders are typically diverse and difficult to be identified.
In this paper, we propose a novel C onfounder
I dentification-free C ausal Visual F eature Learning ( CICF ) method, which obviates the need for identifying confounders.
CICF models the interventions among different samples based on the front-door criterion, and then approximates the global-scope intervening effect based on the instance-level intervention from the perspective of optimization.
In this way, we aim to find a reliable optimization direction, which eliminates the confounding effects of confounders, to learn causal features.
Furthermore, we uncover the relation between CICF and the popular meta-learning strategy MAML (Finn et al., 2017), and provide an interpretation of why MAML works from the theoretical perspective of causal learning for the first time.
Thanks to the effective learning of causal features, our CICF enables models to have superior generalization capability.
Extensive experiments on domain generalization benchmark datasets demonstrate the effectiveness of our CICF , which achieves the state-of-the-art performance.
I NTRODUCTION
Deep learning excels at capturing correlations between the inputs and labels in a data-driven manner, which has achieved remarkable successes on various tasks, such as image classification, object detection, and question answering (Liu et al., 2021;
He et al., 2016;
Redmon et al., 2016;
He et al., 2017; Antol et al., 2015).
Even so, in the field of statistics, correlation is in fact not equivalent to causation (Pearl et al., 2016).
For example, when tree branches usually appear together with birds in the training data, deep neural networks (DNNs) are easy to mistake features of tree branches as the features of birds.
A close association between two variables does not imply that one of them causes the other.
Capturing/modeling correlations instead of causation is at high risk of allowing various confounders to infiltrate into the learned feature representations.
When affected by intervening effects of confounders, a network may still make correct predictions when the testing and training data follow the same distribution, but fails when the testing data is out of distribution.
This harms the generalization capability of learned feature representations.
Thus, learning causal feature, where the interference of confounders is excluded, is important for achieving reliable results.
As shown in Fig.
1, confounders C bring a spurious (non-causal) connection X ←− C −→ Y between samples X and their corresponding labels Y .
A classical example to shed light on this is that we can instantiate X, Y, C as the sales volume of ice cream, violent crime and hot weather.
Seemingly, an increase in ice cream sales X is correlated with an increase in violent crime Y .
However, the hot weather is the common cause of them, which makes an increase in ice cream sales to be a misleading factor of analyzing violent crime.
Analogically, in deep learning, once the misleading features/confounders are captured, the introduced biases may be mistakenly fitted by neural networks, thus leading to the detriment of the generalization capability of learned features.
In theory, we expect DNNs to model the causation between X and Y .
Deviating from such expectation, the interventions of confounders C make the learned model implicitly condition on C .
This makes that the regular feature learning does not approach the causal feature learning.
To learn causal features, previous studies (Yue et al., 2020; Zhang et al., 2020; Wang et al., 2020b) adopt the backdoor criterion (Pearl et al., 2016) to explicitly identify confounders that should be adjusted for modeling intervening effects.
However, they can only exploit the confounders that are accessible and can be estimated, leaving others still intervening the causation learning.
Moreover, in many scenarios, confounders are unidentifiable or their distributions are hard to model (Pearl et al., 2016).
Theoretically, front-door criterion(Pearl et al., 2016) does not require identifying/explicitly modeling confounders.
It introduces an intermediate variable Z and transfers the requirement of modeling the intervening effects of confounders C on X → Y to modeling the intervening effects of X on
Z → Y .
Without requiring explicitly modeling confounders, the front-door criterion is inherently suitable for wider scenarios.
However, how to exploit the front-door criterion for causal visual feature learning is still under-explored.
In this paper, we design a Confounder Identification-free Causal visual Feature learning method ( CICF ).
Particularly, CICF models the interventions among different samples based on the frontdoor criterion, and then approximates the global-scope intervening effect based on the instance-level interventions from the perspective of optimization.
In this way, we aim to find a reliable optimization direction, which eliminates the confounding effects of confounders, to learn causal features.
There are two challenges we will address for CICF .
1) How to model the intervening effects from other samples on a given sample in the training process.
2) How to estimate the global-scope intervening effect across all samples in the training set to find a suitable optimization direction.
As we know, during training, each sample intervenes others through its effects on network parameters by means of gradient updating.
Inspired by this, we propose a gradient-based method to model the intervening effects on a sample from all samples to learn causal visual features.
However, it is intractable to involve such modeled global-scope intervening effects in the network optimization, which requires a traversal over the entire training set and is costly.
To address this, we propose an efficient cluster-then-sample algorithm to approximate the global-scope intervening effects for feasible optimization.
Moreover, we revisit the popular meta-learning method Model-Agnostic
Meta-Learning (MAML)
(Finn et al., 2017).
We surprisingly found that our CICF can provide an interpretation on why MAML works well from the perspective of causal learning: MAML tends to learn causal features.
We validate the effectiveness of our CICF on the Domain Generalization (DG) (Wang et al., 2021;
Zhou et al., 2021a) task and conduct extensive experiments on the PACS, DigitsDG, Office-Home, and VLCS datasets.
Our method achieves the state-of-the-art performance.
R ELATED W ORK
Causal Inference aims at pursuing the causal effect of a particular phenomenon by removing the interventions from the confounders (Pearl et al., 2016).
Despite its success in economics (Rubin, 1986), statistics (Rubin, 1986; Imbens & Rubin, 2015) and social science (Murnane & Willett, 2010), big challenges present when it meets machine learning, i .
e ., how to model the intervention from the confounders and how to establish the causal model.
A growing number of works have moved a step forward by taking advantage of the back-door criterion (Pearl et al., 2016) on various tasks, e .
g .
, few-shot classification (Yue et al., 2020), vision-language task (Wang et al., 2020b), domain adaptation (Yue et al., 2021), class-incremental learning (Hu et al., 2021), and semantic segmentation (Zhang et al., 2020).
Limited by the back-door criterion, most of them are required to identify and model the distributions of the confounders.
However, this may be challenging in the real world because confounders are typically diverse and usually appear implicitly.
To get rid of the dependency on confounders, Yang et al.
(2021), for the first time, propose to utilize the front-door criterion to establish a causal attention module for vision-language task.
However, it still requires the modeling of intervention in the testing stage, which is complicated.
In contrast, this work is the first attempt to apply the front-door criterion for learning causal visual features by considering the intervention among samples.
Ours improves the generalization ability of
DNNs from the optimization perspective and is confounder identification-free.
Model Generalization plays a prominent role for DNNs to be applied in real-world scenarios.
To improve the performance on the testing dataset which has distribution shift (Sun et al., 2016) with training data, various domain generalization (DG) (Muandet et al., 2013; Zhou et al., 2021a; Wang et al., 2021;
Shen et al., 2021; Wei et al., 2021) methods have been proposed.
In general, these methods can be divided into three categories, i .
e ., domain-invariant representation learning, data or feature manipulation, and meta-learning.
The first category intends to learn domain-invariant features that follow the same distributions (Muandet et al., 2013; Li et al., 2018b; Taori et al., 2020; Li et al., 2018d; Motiian et al., 2017; Mahajan et al., 2021b; Jin et al., 2020).
The second category aims to improve the generalization ability of models through enriching the diversity of source domains, either in image space ( e .
g ., CrossGrad (Shankar et al., 2018), DDAIG (Zhou et al., 2020a) and MADA (Qiao et al., 2020)), or feature space (
MixStyle (Zhou et al., 2021c) and RSC (Huang et al., 2020)).
Another new line of DGs utilize meta-learning as training strategy (Zhao et al., 2021; Liu et al., 2020;
Li et al., 2018a; 2020; Wei et al., 2021; Balaji et al., 2018).
MAML (Finn et al., 2017) takes the advantage of meta-learning to find a good parameters initialization for fast adaptation to new tasks.
Following MAML, Li et al.
(2018a)
; Dou et al.
; Li et al.
Balaji et al.
(2018) introduce meta-learning into DG to simulate domain shift or learn domain-invariant parameters regularizer during training.
Other variants of DGs exploit episodic training (Li et al., 2019) and ensemble learning (Zhou et al., 2021b;
Seo et al., 2020; Cha et al., 2021).
In this paper, from a new perspective, we propose a scheme for model generalization termed as
Confounder Identification-free Causal Visual Feature Learning ( CICF ).
P ROPOSED M ETHOD
In this section, we first depict a supervised learning process in a causal graph (Pearl, 2009b), and uncover the stumbling effects of confounders which prevent the achievement of high generalization capability of models in Sec. 3.1.
Then, in Sec. 3.2, based on the front-door criterion, we elaborate our Confounder Identification-free Causal Visual Feature Learning( CICF ) from two perspectives, respectively as how to model mutual intervening effects between different instances and how to approximate such intervening effects from the global scope.
Furthermore, we describe our CICF which alleviates the intervening effects from the optimization perspective in Sec. 3.2.
In Sec. 3.3, we uncover the relation between our CICF and the popular meta-learning strategy MAML (Finn et al., 2017), and provide an interpretation of why MAML works from the theoretical perspective of causal inference.
3. P ROBLEM D EFINITION AND A NALYSIS
Given a training dataset with input and label pairs { X, Y } , the goal of training Deep Neural Networks is to learn/capture the causation between input samples X and prediction labels Y , i .
e ., the conditional probability P ( Y | do ( X )) .
As shown in Fig.
2 (a), we parameterize the network as φ and separate it into two successive parts, i .
e ., h and f .
DNNs capture label-associated features which are not necessarily the casual ones due to the intervening effects of confounders, such as background, brightness, and viewpoint.
We denote the intermediate features and confounders as Z and C , respectively.
Fig.
2 illustrates the relations in a causal graph.
Intervened by the confounders, the conditional probability P ( Y | X ) learned by the model φ actually involves two paths, i .
e ., X −→ Z −→ Y and X ←− C −→ Y .
X −→ Z −→ Y denotes the expected causal effect from the input samples
X to their prediction labels Y .
The path X ←− C −→ Y denotes the non-causal correlation between X and Y due to their common cause C , which may introduce biases into the learning of P ( Y | X ) and thus affect the generalization capability of model φ .
Intuitively, it is crucial to get rid of the harmful bias from those confounders for causal feature learning.
In the literature of causal inference (Pearl et al., 2016), the confounding effects from confounders can be removed through the do operation (Pearl et al., 2016) by cutting off the connection from C to X , as illustrated in Fig.
1 (b).
With the definition of do operation, the real causation from X to Y can be formulated by P ( Y | do ( X )) .
The objective of our CICF is to learn features representation conforming to P ( Y | do ( X )) .
Back-door criterion.
In previous works (Yue et al., 2020; Wang et al., 2020b; Hu et al., 2021), when C is identifiable, the back-door criterion (Pearl et al., 2016) is typically utilized to achieve the do operation as:
[Equation]
which acquires access to the distributions of all confounders c ∈ C .
However, in many scenarios, the intervening effects are caused by unobservable or implicit factors.
It is not feasible to identify the distribution of C during training, limiting the usage of the back-door criterion.
Front-door criterion.
For unidentifiable confounders, the F ront-door criterion (Pearl et al., 2016) provides us with a more practical alternative to E stimate the I ntervening E ffect, called FEIE , eschewing the identification of confounders C .
Specifically, it introduces an intermediate variable Z to help assess the effect of X on Y , i .
e ., P ( Y | do ( X )) , which can be formulated as:
[Equation]
where Z = h ( X ) , ˜ x ∈ X denotes a sample from training data.
Note that the effect of X on Z is identifiable because they have no common causes.
In other words, there is no backdoor path from
X to Z .
Thus, we have P ( Z =
z | do ( X = x ))
=
P ( Z = z | X = x ) .
Front-door criterion is attractive for eliminating interventions.
However, it is still under-explored for visual feature learning, where there is a lack of a simple and practical mechanism to exploit this theory for enhancing the generalization capability of models.
3. C ONFOUNDER I DENTIFICATION - FREE C AUSAL V ISUAL F EATURE L EARNING
In this paper, we aim to achieve Confounder Identification-free Causal Visual Feature Learning , obviating the need for confounder identification.
As indicated by Eq.
(2), thanks to the frontdoor criterion, we do not need to identify and explicitly model confounders C .
Despite this, it still imposes a challenge on how to accurately model the term (cid:80)
˜ x P ( Y | Z
= z, ˜ x ) in the network training process.
We treat the first part of φ as the model h to obtain the intermediate variable z , i .
e .,
z = h ( x ) .
Because the parameters of h are fixed in the inference stage and z = h ( x ) is known given any x ∈ X , P ( Z = z | X = x ) is equal to 1 1 .
Thus, we can re-write Eq.
(2) as:
[Equation]
where P ( Y | Z
=
h
( x ) , ˜ x ) denotes the mutual intervening effects to the causation path Z −→ Y from another sample ˜ x .
With the summation operation, Eq. 3 represents the global intervening effects accumulated from all samples in the training data.
We will describe the instantiations of
P ( Y | Z
= h ( x ) , ˜ x ) and the accumulation in Eq.
(3) respectively as below.
A Gradient-based Instantiation of FEIE .
Referring to the practices in prior works (Yue et al., 2020; Wang et al., 2020a) upon the back-door criterion, a straightforward method for modelling
P ( Y | Z
= h ( x ) , ˜ x ) is to directly concatenate z = h ( x ) and the feature of ˜ x ∈ X before feeding them into f .
However, this method would easily lead to a trivial solution once the information of ˜ x is ignored by the layers of the neural networks.
In contrast, we propose to explicitly model the intervening effects of ˜ x on Z −→ Y with a gradient-based instantiation.
We notice that, in the training process, the influence of one instance on others can be reflected on the parameters updating with the gradient obtained based on this instance .
Therefore, for a given sample x , we propose to explicitly model the intervening effects P
( Y | Z
= h ( x ) , ˜ x ) of another sample ˜ x on x through f as:
[Equation]
, where
[Equation]
f θ and f θ ˜ x denote the model f before and after the parameters updating respectively, g ˜ x denotes the calculated gradient with respect to the sample ˜ x and its label ˜ y .
L and α represent the loss of cross entropy and learning rate, respectively.
Incorporating Eq.
(4) into Eq.
(3), we have Eq.
(5) as below to explicitly eliminate the interventions of all samples on the sample x as:
[Equation]
Global-scope Intervening Effects Approximation.
With the above introduced gradient-based instantiation, the globally accumulative intervening effects from all the training samples can be estimated by a traversal on X , which, however, is time- and memory-consuming in practice.
To achieve an efficient estimation in the global scope, we apply the first-order Taylor’s expansion on Eq.
[Equation]
Eq.
(6) reveals that the key to estimating P ( Y | do ( X )) lies in computing the global-scope gradient g † = (cid:80)
˜ x ∈ X g ˜ x P (˜ x ) over all ˜ x ∈ X accumulated via weighted sum with P (˜ x ) as the weight.
However, it is intractable to directly compute the global-scope gradient g † by traversing over all the training samples.
Alternatively, we can traverse over a sampled small subset that shares the similar data distribution to that of all the training data.
As we know, when the training data are unbalanced and diverse, random sampling of a small subset would result in bias that mismatches the distribution of the dataset, leading to an inaccurate estimation of the global-scope gradient.
To better estimate the data distribution and thus approach the global-scope gradient, we propose a sampling strategy dubbed as clustering-then-sampling .
More discussion/analysis can be found in the Appendix A.1.
Concretely, we first cluster the training samples of each class in the dataset into K clusters with
K -means algorithms (Pelleg et al., 2000) and totally obtain K † clusters for the whole training data.
It is noteworthy that we found the samples in each cluster usually have similar gradient directions in optimization.
Thus we represent each cluster with fewer samples randomly sampled from the same cluster, avoiding traversing over all the data.
Then, the global-scope gradient g † can be approximated with weighted sum over the sampled M = (cid:80) K † k =
N k samples from K † clusters:
[Equation]
where N k is the number of instances sampled from the k -th cluster (being proportional to the size of this cluster), g ˜ x j,k ∈ K k denotes the gradients of the sample ˜ x j,k ∈ K k .
Combined with Eq.
(7), we rewrite Eq.
(6) as:
[Equation]
Causal Visual Feature Learning.
Based on the above theoretical analysis and the proposed intervention approximation strategy, the intractable causal conditional probability P ( Y | do ( X )) can be approximated based on Eq.(8), without requiring the identification of confounders C .
Actually, the
Eq.
(8) can be viewed as the first-order Taylor’s expansion of f θ − αg † ( h ( x )) .
Thus, we have:
[Equation]
here let θ † = θ − αg † (the parameters of f ), which are updated with the global-scope gradient g † .
The output of a model is thus denoted as ˆ y do ( x ) =
f θ † ( h ( x )) , which has been aware of the global-scope interventions from all other samples on the current sample x based on such global-scope gradient updated model ( i.e. , f θ † ).
Then, we can train an unbiased model f to learn the causal visual features with the loss of cross-entropy:
[Equation]
where y is the corresponding ground-truth label for x .
The overall algorithm of Confounder
Identification-free Causal Visual Feature Learning is described in Alg.
1 of Appendix.
Note that clustering-then-sampling is better than random sampling to approach the distribution of the training dataset, thereby being capable of approximating the global-scope gradient more accurately.
We have theoretically analyzed that clustering-then-sampling has a more minor standard error (SE) for estimating the distribution of all the training data than random sampling, i .
e .,
SE ours < SE random in the Appendix A.1.
This demonstrates that our clustering-then-sampling is a more efficient and more accurate strategy to estimate the data distribution and then the global-scope gradient.
3. D ISCUSSION
In this section, we will provide an analysis and comparison between our CICF and MAML (Finn et al., 2017).
For the first time, we interpret why MAML works from a causal learning perspective, which is supported by our analysis in the previous subsections.
In the seminal work MAML (Finn et al., 2017), Finn et al .
propose a model-agnostic meta-learning strategy that treats a batch of data as meta-train and another batch of data as meta-test for optimization.
Particularly, given T sets of data { D ttr , D tte } Tt =1 corresponding to T tasks {T t } Tt =1 , where D ttr and D tte denote meta-train and meta-test data respectively, the loss function of MAML for optimization can be represented as:
[Equation]
(11) where θ ttr refers to the parameter virtually updated with the gradient g ttr calculated on D
ttr , i .
e ., θ ttr ← θ − αg ttr , which is treated as meta-train task.
The optimization on D tte is treated as meta-test task, where the parameters are updated as θ tte ← θ − α ∇ θ L MAML .
They interpret why MAML works from the perspective that it can provide a good parameter initialization which is robust for fast adaptation to new data.
However, there is a lack of theoretical analysis and support in Finn et al.
Based on our analysis in Section 3.2, for the first time, we have a new understanding of the previous uses of MAML (Finn et al., 2017;
Li et al., 2018a)
(see Eq.
from the perspective of causal inference .
L (cid:0) f
θ ttr
( X tte ) , Y t te (cid:1) in Eq.
(11) actually models the intervention from meta-train data D ttr to meta-test data D tte within the task t and endeavors to eliminate such local data modeled intervention.
However, as revealed by our theoretical analysis in Section 3.2, learning reliable causal features requires the capturing and modeling of interventions from all the samples ( i .
e ., global interventions).
There is no such solution in the previous works while we provide a practical and efficient one to model and eliminate the global-scope interventions in this paper.
This enables reliable causal feature learning and promotes the achievement of higher generalization capability of models.
[Table]
E XPERIMENTS
To validate the effectiveness of our CICF
[Table]
we apply it on the Domain Generalization (DG)
(Zhou et al., 2021a;
Wang et al., 2021) task
[Table]
where the models are expected to learn the unbiased causal features to be generalized to different domains.
We describe the datasets and implementation details in Sec. 4.1.
Then we clarify the effectiveness of each component of our CICF in Sec. 4.
[Table]
and compare with previous methods in Sec. 4.3.
Finally, we qualitatively show that CICF captures the causal features in Sec. 4.4.
4. D ATASETS AND I MPLEMENTATION D ETAILS
Datasets.
We evaluate our method on four commonly used benchmark datasets ( i
[Table]
e ., PACS (Li et al., 2017), Digits-DG, Office-Home (Venkateswara et al., 2017) and VLCS (Torralba & Efros, 2011)) for Domain Generalization.
1) PACS (Li et al., 2017) contains images from four domains, i .
e .,
Photo (P),
Art painting (A), Cartoon (C), and Sketch (S).
Each domain consists of images in seven object categories.
2) Digits-DG is composed of four digit datasets, including MINIST (LeCun et al., 1998),
MINIST-M (Ganin & Lempitsky, 2015), SVHN (Netzer et al., 2011) and SYN (Ganin & Lempitsky, 2015).
Each dataset is regarded as a domain, which contains ten digit categories from zero to nine.
3) Office-Home is divided into four domains, including Artistic, Clipart, Product and Real World.
There are 65 object categories related to the scenes of office and home. 4) VLCS
(Torralba &
Efros, 2011) covers images of five object categories from four domains, i .
e ., PASCAL VOC 2007,
LabelMe, Caltech, and Sun datasets.
Following previous DG methods (Li et al., 2019; Zhou et al., 2021c; Li et al., 2018b;a), we evaluate methods under the leave-one-domain-out protocol, where one domain is used
Implementation Details.
For PACS and Office-Home, we take ResNet18 (He et al., 2016) pretrained on ImageNet (Deng et al., 2009) as backbone, following Zhou et al.
(2021c)
; Carlucci et al.
We also take the ResNet-50 pretrained on ImageNet as the backbone for PACS, following
Huang et al.
For VLCS, we take AlexNet (Krizhevsky et al., 2012) pretrained on ImageNet (Deng et al., 2009) as our backbone, which is the same as (Matsuura & Harada, 2020; Dou et al., 2019).
For Digits-DG, we adopt the model architecture used in previous works (Zhou et al., 2020b; 2021c).
We cluster three clusters within each class in training datasets.
All reported results are averaged among six runs.
More implementation details can be found in the Appendix A.5.
4. A BLATION S TUDY
Effectiveness of CICF .
Our proposed CICF enables models to have superior generalization ability by effectively causal feature learning.
We compare our CICF with the popular
Method
A
C
P
S Avg.
MatchDG
[Table]
meta-learning strategy MAML, which aims to explore the commonly optimal optimization direction for all tasks ( i .
e ., different domains), on two baselines.
1) ERM: training models only on source domains with simple data augmentations including flip and translation.
2) ERM ∗ : training models on source domains with AutoAugment (Cubuk et al., 2018).
The results on PACS are shown in Table 1, with baseline ERM,
ERM+ CICF outperforms ERM by 2.4 % in accuracy without known domain labels , while MAML only achieves the improvement of 0.1% with known domain labels .
Moreover, with another baseline, ERM ∗ + CICF outperforms ERM ∗ by 3.2% and 2.0% on PACS and Digits-DG respectively.
However, MAML is not robust for different baselines and does not work for ERM ∗ .
Different ways to estimate global-scope intervening effects.
To estimate the global-scope intervening effects efficiently and accurately, we propose a clustering-then-sampling strategy.
An alternative is the na¨ıve random mini-batch sampling.
As shown in Fig. 3(a), the classification accuracy increases along with the increased sampling batch-size.
This is because increasing batch-size will result in a better estimation of the global-scope intervention with lower SE.
However, the memory overhead increases drastically simultaneously.
In contrast, our clustering-then-sampling outperforms the na¨ıve random sampling by 0.7% with lower memory utilization (the batch-size is fixed as
256 for PACS in our case).
We also conduct experiments on the influence of the number of clusters
K † for all datasets.
The results in Fig. 3(b) show that more clusters result in better performance, and the performance is saturated when K † = 21 for PACS ( i .
e ., three clusters for each class).
Because more clusters lead to lower intra-cluster variance σ k of the k th cluster and more accurate estimation of the global-scope intervention with lower SE, which is derived in the Appendix A.1.1.
And three clusters for each class are enough for global-scope intervention modeling.
Different choices of Z .
We explore the effects of different choices of Z from shallow layer features to deep layer features.
The experiments and analysis are shown in Appendix A.4, which reveals that shallow features are better.
4. C OMPARISON WITH S TATE - OF - THE - ARTS
PACS.
As shown in Table 1, our proposed CICF on top of ERM ∗ achieves the best performance on PACS, outperforming the SOTA works including MixStyle (Zhou et al., 2021c),
RSC (Huang et al., 2020), MatchDG (Mahajan et al., 2021a) and FACT Xu et al.
Moreover, ERM ∗ + CICF is clearly better than previous gradient-based and meta-learning based methods, e .
g ., CrossGrad (Shankar et al., 2018), MLDG (Li et al., 2018a), MetaReg (Balaji et al., 2018), and MAML (Finn et al., 2017), thanks to the more accurate global intervening effects modeling in
CICF .
On the most challenging domain sketch , our ERM ∗ + CICF outperforms all previous methods by a large margin ( ≥ 2.3% ), which demonstrates that CICF can learn the causal visual features by removing the influence from confounders efficiently.
The experiments on PACS with ResNet-50 are shown in Table 2, where our CICF is clearly superior to the SOTA methods, e.g., RSC (Huang et al., 2020), MatchDG (Mahajan et al., 2021a),
FACT (Xu et al., 2021) and recent Fish (Shi et al., 2021).
Digits-DG.
As shown in Table.
1, our ERM ∗ + CICF achieves the best performance, outperforming the MAML (Finn et al., 2017) by 1.4% and the recent MixStyle
(Zhou et al., 2021c) by 5.2%.
For the most challenging domains ( i .
e ., MNIST-M and SVHN), ERM ∗ + CICF improves the accuracy of
ERM ∗ by 3.8% and 2.5% respectively.
Office-Home.
As shown in Table 3 of Appendix, our ERM ∗ + CICF achieves the best performance of 66 .
2% , exceeding the previous state-of-the-art method MixStyle (Zhou et al., 2021c) by 0.7%.
Furthermore, ERM ∗ + CICF improves ERM ∗ on the challenging Clipart by a margin of 3.2%.
VLCS.
The results on VLCS are shown in Table 4 of Appendix, where our ERM ∗ + CICF achieves the state-of-the-art result, outperforming the second best MASF (Dou et al., 2019) by 0.6%, which is based on meta-learning.
Moreover, CICF brings the improvement of 1.7% for ERM ∗ .
4. F EATURE V ISUALIZATION
To validate that CICF actually learns the causal visual features, we visualize and compare the
Grad-CAM (Selvaraju et al., 2017) of ERM and ERM+ CICF in Fig.
Intervened by the confounders ( e .
g ., background), ERM easily focuses on the object-irrelevant regions ( i .
e ., non-causal features), impeding the model’s generalization ability.
In contrast, thanks to the guidance of CICF ,
ERM+ CICF is prone to focus more on the foreground object regions ( i .
e ., causal features).
Further, we visualize the learned features by t-SNE (Saito et al., 2019) on Digits-DG in the Appendix A.6.
C ONCLUSION
In this paper, we propose a novel method dubbed Confounder Identification-free Causal Visual Feature Learning ( CICF ) for learning causal visual features without explicit identification and exploitation of confounders.
Particularly, motivated and based on the front-door criterion, we model the interventions among samples and approximate the global-scope intervening effects for causal visual feature learning.
Extensive experimental results on domain generalization validate that
our
CICF can help a model to achieve superior generalization capability by learning causal features, without the need of identifying confounders.
Our method is generic which should be applicable to other fields such as NLP.
We leave this as future work.
A A PPENDIX A. M ORE D ETAILS ON CICF A.1. S TATISTICAL A NALYSIS ON S AMPLING A LGORITHMS
In this section, we provide the statistical analysis for the superiority of our proposed sampling strategy, i .
e ., clustering-then-sampling , by comparing it to the random mini-batch sampling strategy.
As a result, we theoretically derive that using our clustering-then-sampling has a significant smaller standard error (SE) in estimating the global-scope gradient, compared with using the random minibatch sampling strategy.
Given a training dataset D =
( x i , y i )
Ni =1 , the global-scope gradient can be computed as:
[Equation]
However, it is intractable to compute g † with Eq.
12 directly, which requires traversing over all training data.
Our clustering-then-sampling aims to simulate the global-scope gradient with partial data from the training dataset.
Another alternative na ¨ ıve method is random mini-batch sampling.
Random mini-batch sampling.
With this strategy, the gradient g random of each iteration is computed over a mini-batch data { x rj , y rj } M j =1 , where the mini-batch data with size M is randomly sampled from the training data:
[Equation] [Equation]
According to the sampling theory (Ghosh, 2002), the expectation of g random can be represented as:
[Equation] [Equation]
where µ denotes the expectation of gradients of all samples in the training data.
To measure this strategy’s estimation accuracy of approximating the global-scope gradient g random in Eq.
12, we can derive its SE as:
[Equation]
where σ 2 is the variance of the gradients of all training samples.
Considering M ≪ N , Eq.
15 can be further approximated as:
[Equation]
16) clustering-then-sampling .
In contrast, in our clustering-then-sampling, we first cluster the training samples of each class in the dataset into K cluster with K -means algorithm (Pelleg et al., 2000) and totally obtain K † clusters for the whole training data.
We denote the mean and variance of the gradients of the k th cluster K k as µ k and σ 2 k respectively.
Since the clustering, the variance of the sample distribution in each cluster is significantly smaller than the variance of the sample distribution in whole training data.
Therefore, the gradient variance of the k th cluster σ 2 k is smaller than σ 2 .
Then we sample N k samples from the k th cluster to form a mini-batch with the size of
M ( i .
e ., M = (cid:80) K † k =1 N k ).
Here, N k is proportional to the ratio P ( K k )
( i .
e .,
N k = MP ( K k ) ) and P ( K k ) is ratio of the size of the k th cluster N Kk to the size of entire training data
N ( i .
e .,
P ( K k ) =
N Kk N ).
Then the global-scope gradient can be computed with:
[Equation]
▷ Eq. ▷ Eq.
Based on stratified sampling theory (Ghosh, 2002), the expectation of g ours can be computed as:
[Equation]
The standard error (SE) of our clustering-then-sampling can be derived as :
[Equation] [Equation]
where N Kk denotes the number of all samples in the k th cluster.
Considering N k ≪ N Kk ,
[Equation]
In clustering, the intra-cluster gradient variance σ 2 k reduces with the increasing the number of clusters.
Thus, we can get σ 2 k < σ 2 when 1 ≤ k ≤ K † .
We represent the maximum value of σ 2 k as ( σ 2 k ) max = max { σ 2 k | 1 ≤ k ≤ K † } .
The Eq.
20 can be rewritten as:
[Equation]
Based on the Eq.
21, we can draw a conclusion that our clustering-then-sampling is better than random mini-batch sampling for simulating the global-scope gradient accurately.
Furthermore, from the Eq. 21, we can let ( σ 2 k ) max ≪ σ 2 by increasing the number of clusters, and obtain the SE ours ≪
SE random .
A.1. E XPERIMENTAL E VIDENCE FOR THE S IGNIFICANT D IFFERENCE BETWEEN TWO S AMPLING S TRATEGIES .
To further demonstrate the difference between our clustering-then-sampling and random mini-batch sampling , we introduce a metric E = (cid:80) K † k =1 ( | N k − R k | ) to measure the difference degree between two sampling strategies, where N k and R k denote the number of sampled instances from the k th cluster using clustering-then-sampling and random mini-batch sampling , respectively.
We conduct two experiments on PACS with batch-size M = 256 as follows.
We cluster three clusters for each of the seven classes in PACS and totally obtain 21 clusters.
The average E is 55, i .
e ., the difference ratio E/M between clustering-then-sampling and random mini-batch sampling is 55 / 256 = 21 .
We consider the class prior for random mini-batch sampling , and adopt the random mini-batch sampling weighted by the number of each class.
We have E as 46 and the difference ratio E/M = 46 / 256 = 18 . 0% .
Based on the above experiments, we can find that our clustering-then-sampling is significantly different from random mini-batch sampling .
A.1. M ORE D ETAILS ON THE S ETTING OF S AMPLING A LGORITHM
Our CICF aims to simulate the global intervening effects from the perspective of optimization with:
[Equation]
where a mini-batch sampling procedure is applied to ˜ x j,k ∈ K k ( i .
e ., clustering-then-sampling).
After obtaining the updated θ † with θ † = θ − α ∗ g † , we can obtain the loss function L CICF and get the reliable optimization direction against the intervening effects of confounders:
[Equation]
where another mini-batch sampling procedure is applied to the variable x .
As above, there are two mini-batch sampling in our CICF adopted for computing global-scope gradient and loss function L CICF respectively.
They are denoted by { ˜ x, ˜ y } Mi =1 and { x, y } M l i =1 , respectively.
To clarify the composition of the samples in each mini-batch, we first define some notations, respectively as follows:
• N : The number of all samples in the training dataset • N Kk : The number of all samples in the k th cluster.
• N k : The number of sampled samples in the k th cluster to form a mini-batch.
• M : The number of all samples in a mini-batch for computing global-scope gradient.
• M l : The number of all samples in a mini-batch for computing L CICF .
• P ( K k ) :
The ratio of all samples N Kk in the k th cluster to all training data N , which is represented as P ( K k ) =
N Kk N
For computing global-scope gradient, we respectively sample N k samples from the k th cluster to form a mini-batch { ˜ x, ˜ y } Mi =1 .
N k can be set with two strategies, respectively N k = MP ( K k ) and
N k = MK † , responding to two scheme for computing L CICF .
When we directly consider the unbalance question between different clusters in computing L CICF , we can sample M l K † samples from each cluster to form a mini-batch { x, y } M l i =1 , and corresponding
N k is N k = MK † .
On the contrary, when we randomly sample M l samples from all training data to compute L CICF , the corresponding N k is N k = MP ( K k ) , which needs to model the intervention caused by the unbalance question.
A. M ORE D ETAILS ON B ACK - DOOR /F RONT - DOOR CRITERION
Back-door and front-door criteria have been proposed in Pearl et al.
; Pearl (2009a) to reveal the causality between two variables X and Y .
We further clarify their basics mathematically in this section.
Back-door criterion.
Fig.
5 shows the back-door criterion, which targets for removing the intervention effects with do operation.
Do operation denotes a surgery to cut off the connection from
C to X .
From Fig.
5(a), the P ( Y | X ) is associated with two paths, respectively as X ←− C −→ Y and X −→ Y .
Here X ←− C −→ Y is a spurious path, which intervenes the estimation of causality between X and Y , denoted as P ( Y | do ( X ))
( i .
e ., the Fig. 5(b)).
Following the Pearl et al.
(2016), we can denote the conditional probability between X and Y in Fig. 5(b) as P m ( Y | X ) .
Since C has no parent-level variable, the P m ( C ) =
P m ( C | X ) in the Fig.
5(b) is equivalent to the P ( C ) in the
Fig. 5(a).
Furthermore, we can get the P m ( Y | X, C ) in the Fig. 5(b) is equivalent to P ( Y | X, C ) in the Fig.
5(a) since the same graph architecture.
Based on the above definition, the back-door criterion can be derived as:
[Equation]
Then we can get the formulation of the back-door criterion as:
[Equation]
Front-door criterion.
From Eq.
24, we can draw a conclusion that estimating the causality between X and Y ( i .
e ., P ( Y | do ( X ) ) requires traversing the distribution of confounders C .
However, confounders C are in general diverse and not identifiable.
To solve the above question, as shown in
Fig.
6, the front-door criterion introduces an intermediate variable Z and transfers the requirement of modeling the intervening effects of confounders C on X −→ Y to modeling the intervening effects of X on Z −→ Y (Pearl et al., 2016).
Specifically, front-door criterion decompose the P ( Y | do ( X )) into two components, i .
e ., P ( Y | do ( Z )) and P ( Z | do ( X )) , which can be represented as:
[Equation]
As shown in Fig. 6(a), the variables X and Z do not have common causes, which reveals the path
X −→ Z is not intervened by other variables.
Therefore, the causality between X and Z is equivalent to its correlation as:
[Equation]
From Fig.
6(a), the path Z −→ Y is intervened by two variables, respectively as C , X , since the existing spurious path Z ←− X ←− C −→ Y .
Then we can simply block this spurious path by cutting off the path X −→ Z with back-door criterion (Pearl et al., 2016), which gets rid of identifying the confounders C .
[Equation]
Based on Eq.
27 and 28, we can derive Eq.
26 as:
[Equation]
Then we can obtain the formulation of the front-door criterion as Eq. 29.
A. U SING h ( X ) AS Z SATISFIES FRONT - DOOR CRITERION
In this section, we give the proof that using h ( x ) as Z satisfies the front-door criterion.
As depicted in Pearl et al.
, the definition of the front-door criterion is as following:
Definition: if Z satisfies the front-door criterion relative to an ordered pair of variables ( X, Y ) , it must obey the following principles: 1) Z intercepts all directed paths from X to Y . 2)
There is no unblocked back-door path from X to Z . 3)
All back-door paths from Z to Y are blocked by X .
We prove that ours satisfy the above principles as:
• As shown in Fig.
2, the direct path from X to Y is built from the model φ , that is composed of two sub-models, h and f .
We can represent this path as Z = g ( X ) , Y =
f ( Z ) .
We can observe that Z intercepts all directed paths from X to Y , which satisfies the Principle 1) .
• The second principle requires there is no unblocked back-door path from X to Z , ( i.e., P ( Z | do ( X ))
=
P ( Z | X ) ), which is a vital factor in ensuring that the causal effects can be estimated.
We interpret that ours satisfy this principle from two perspectives.
1) As shown in Fig.
2, the effect of confounders C to Z is transmitted by X through a sub-model f as C −→ X f −→ Z instead of X ←− C −→ Z , which indicates that there is no backdoor from X to Z and thus no common confounders for X and Z. 2)
We prove this from contradiction.
From the theory of the back-door criterion, if there are common confounders C for X and Z, then P ( Z | do ( X ))!
=
P ( Z | X ) .
In fact, when Z = h ( X ) is obtained from a deterministic mapping of X at the inference stage, we always have P ( Z |
X
C )
=
P ( Z | X ) for any confounder C.
Then we can derive that P ( Z | do ( X ))
= (cid:80) C =
c P ( Z | X, c ) P ( c )
=
(cid:80) C =
c P ( Z | X ) P ( c ) =
P ( Z | X ) .
This means there are no common confounders for X and Z ( i
e., no unblocked back-door path for X and Z), which satisfies the Principal 2) .
• There are two paths from Z to Y , i
e., Z −→ Y and Z ←− X ←− C −→ Y .
The second path is called the back-door path between Z and Y .
When we condition on X , the back-door path will be blocked.
Therefore, all back-door paths from Z to Y are blocked by X , which satisfies the Principal 3) .
Consequently, exploiting Z = h ( X ) is consistent with the front-door criterion.
Another essential factor for estimating the causal effects by the front-door criterion is P ( X, Z ) > 0 .
That means if P ( X, Z ) =0, the P ( Y | do ( X )) in Eq.
2 is equivalent 0 and cannot be estimated.
In our
CICF , Z is deterministic related to X with Z = f ( X ) .
Based on the probability theory P
( X, Z ) =
P ( X ) P ( Z | X ) .
Since Z = f ( X ) , the P ( Z | X )
=
P ( f ( X ) | X ) = 1 is always holds when f is fixed at inference stage.
Therefore, P ( X, Z ) =
P ( X ) P ( Z | X ) =
P ( X ) > 0 holds in our method.
A. D IFFERENT CHOICES OF Z
As shown in Fig.
2 (a), the model φ is separated into successive h and f , and Z = h ( X ) is the intermediate output of φ .
To explore the effects of different choices of Z , i .
e ., and different separations of φ , we conduct ablation experiments on PACS.
Fig.
7 shows the different choices of Z based on
ResNet and the corresponding results are shown in Fig. 3(c).
It is observed that the shallower Z is obtained, the better accuracy the results achieved.
We reckon the reason is that selecting Z from shallower layers will result in a larger model for f , which will have more capability to learn the conditional probability P ( Y | do ( Z )) .
In this paper, we set Z =
Z 0 to make f have more parameters to learn causal features.
A. M ORE I MPLEMENTATION D ETAILS
For PACS and Office-Home, we take ResNet18 (He et al., 2016) pretrained on ImageNet (Deng et al., 2009) as backbone, following Zhou et al.
(2021c)
; Carlucci et al.
; Li et al.
(2018a).
For
VLCS, we take AlexNet (Krizhevsky et al., 2012) pretrained on ImageNet (Deng et al., 2009) as our backbone, which is the same as Dou et al.
; Li et al.
; Matsuura & Harada (2020).
For
Digits-DG, we adopt the model architecture used in previous works (Zhou et al., 2020b;
Carlucci et al., 2019;
Zhou et al., 2021c), which is composed of four convolution layers with inserted ReLU and max-pooling layers.
We set the mini-batch size M for computing the global-scope gradient as 256,and the mini-batch size M l for computing L CICF as 84.
We set the batch size to 84 and train the model using SGD optimizer for 60 epochs.
For PACS, the learning rate α and β are set to 0.
and 0.01 respectively.
For VLCS, the learning rate α and β are 0.005 and 0.001 respectively.
As for
Office-Home, we set α , β as 0.001 and 0.001 respectively.
For Digits-DG, we set α , β as 0.5 and 0.1 respectively.
All reported results are averaged among six runs with different seeds.
The GPU memory cost of our CICF is 7.151 GiB and the clustering for training data takesseconds for PACS, which introduces only 4 .
8% extra time to the whole training process ( i .
e .,seconds) while bringing the significant gain of 2.4%.
[Table] [Table]
A. F EATURE V ISUALIZATION
We visualize more Grad-CAM (Selvaraju et al., 2017) of ERM and ERM+ CICF in Fig.
We can observe that our CICF focus more on foreground regions ( i .
e ., the casual features), while ERM easily focuses on the misleading regions ( e .
g ., the bone in the dog of the cartoon, background) when capturing causal features.
As shown in Fig.
9, we visualize the learned feature on Digits-DG by tSNE (Saito et al., 2019).
We find that the distribution of features extracted from ERM+ CICF is more compact across samples with the same category, compared to ERM.
This validates the effectiveness of our algorithm for causal feature learning.
We also visualize the t-SNE visualizations with different random seeds in the Fig.
10 and Fig.
A. M ORE COMPARISONS WITH THE D OMAIN B ED BENCHMARKS .
To further demonstrate the effectiveness of our CICF , we implement our CICF on the baseline
ERM of DomainBed (Gulrajani & Lopez-Paz, 2020) and compare it with the benchmarks used in
DomainBed (Gulrajani & Lopez-Paz, 2020), including IRM (Arjovsky et al., 2019), DRO (Sagawa et al., 2019), Mixup (Xu et al., 2020), MLDG (Li et al., 2018a), CORAL (Sun et al., 2016), MMD (Li et al., 2018b), DANN (Ganin et al., 2016), and C-DANN (Li et al., 2018c).
We utilize the commonlyused datasets Office-Home (Venkateswara et al., 2017), VLCS (Torralba & Efros, 2011), and the synthesized ColorMNIST (Arjovsky et al., 2019).
As shown in the Table 5, Table 6, Table 7,
our
CICF improves the ERM by an average gain of 2% on Office-Home, 1.7% on VLCS and 4.1% on
ColorMNIST.
Our CICF achieves the best performances on these three datasets.
It is noteworthy that even in the most difficult domain in ColorMNIST, our CICF can achieve an accuracy of 21.4%, which exceeds the second method MMD (Li et al., 2018b) by 10.9%.
[Table]
[Table] [Table]