{'fraction_non_alphanumeric': 0.031002469977003663, 'fraction_numerical': 0.011817562388212247, 'mean_word_length': 5.05843653250774, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Do learned representations respect causal relationships?

Data often has many semantic attributes that are causally associated with each other. But do attribute-specific learned representations of data also respect the same causal relations? We answer this question in three steps. First, we introduce NCINet, an approach for observational causal discovery from high-dimensional data. It is trained purely on synthetically generated representations and can be applied to real representations, and is specifically designed to mitigate the domain gap between the two. Second, we apply NCINet to identify the causal relations between image representations of different pairs of attributes with known and unknown causal relations between the labels. For this purpose, we consider image representations learned for predicting attributes on the 3D Shapes, CelebA, and the CASIA-WebFace datasets, which we annotate with multiple multi-class attributes. Third, we analyze the effect on the underlying causal relation between learned representations induced by various design choices in representation learning. Our experiments indicate that (1) NCINet significantly outperforms existing observational causal discovery approaches for estimating the causal relation between pairs of random samples, both in the presence and absence of an unobserved confounder, (2) under controlled scenarios, learned representations can indeed satisfy the underlying causal relations between their respective labels, and (3) the causal relations are positively correlated with the predictive capability of the representations.


Introduction
Consider the face image in Fig. 1a. Automated face analysis systems typically involve extracting semantic attributes from the face. These attributes are often related through an underlying causal mechanism governing the relations between them. Modern computer vision systems excel at predicting such attributes by learning from large-scale annotated datasets. This is achieved by learning compact attribute-specific representations of the image from which the attribute prediction is made. This setting naturally raises the following questions ( Fig. 1b): (1) Can we estimate the causal relations between high-dimensional representations purely from observational data with high accuracy?, (2) Do the learned attribute-specific representations also satisfy the same underlying causal relations, and if so to what extent?, and finally (3) How are the causal relations affected by factors such as the extent of training, overfitting, network architecture, etc. Answering these questions is the primary goal of this paper. Our work is motivated by the empirical observation that modern representation learning algorithms are inclined to uncontrollably absorb all correlations in the data [51]. Consequently, while such systems have exhibited significantly improved empirical performance across many applications, it has also led to unintended consequences, ranging from bias against demographic groups [4] to loss of privacy by extracting and leaking sensitive information [50]. Identifying the causal relations between representations can help mitigate the deleterious effects of spurious correlations. With the proliferation of computer vision systems that employ such representations, it is imperative to devise tools to discover the causal relations given a set of representations.
Discovering causal relations from learned representations poses two main challenges. First, causal discovery typically involves interventions [45] on the data which are either difficult or impossible on the observational representation space. For instance, in the image space, interventions may be possible during the image acquisition process for certain attributes such as hair color, eyeglasses, etc. Such interventions are, perhaps, not possible for attributes such as gender or ethnicity. On the other hand, it is not apparent how to intervene on any of these attributes directly in the representation space. Second, causal discovery methods, for pairs or whole graphs, are typically evaluated on small-scale low-dimensional datasets with multiple related attributes. However, there are no large-scale image datasets labeled with multiple causally associated attributes, nor are there any standardized protocols for evaluating the effectiveness of causal discovery methods on learned representations. While existing datasets such as MSCOCO [33] and CelebA [35] are labeled with multiple attributes they are either not causally related to each other (e.g., MSCOCO) or only have binary labels that suffer from severe class imbalance (e.g., CelebA).
To mitigate these challenges; (1) We propose Neural Causal Inference Net (NCINet) -a learning-based approach for observational causal discovery from high-dimensional representations, both in the presence and absence of a confounder. NCINet is trained on a custom synthetic dataset of representations generated through a known causal mechanism. And, to ensure that it generalizes to real representations with complex causal relations we, (a) incorporate a diverse set of function classes with varying complexity into the data generating mechanism, and (b) introduce a learning objective that is explicitly designed to encourage domain generalization. (2) We develop an experimental protocol where, (a) existing datasets can be controllably resampled to induce a desired known causal relationship between the attribute labels, (b) learn attribute representations from the resampled data and infer the causal relations between them. We adopt three image datasets, namely, 3D Shapes dataset [7], CelebA [35] and CASIA WebFace [61], where we annotate the latter with multiple multi-label attributes.
Contributions: First, we propose a learning-based tool, NCINet, for causal discovery from high-dimensional observational data, both in the presence and absence of a confounder. Numerical experiments on both synthetic and realworld data causal discovery problems indicate that NCINet exhibits significantly better causal inference generalization than existing approaches. Second, we employ NCINet for causal inference on attribute-specific learned represen-tations and make the following observations; (1) Learned attribute-specific representations do satisfy the same causal relations between the corresponding attribute labels under controlled scenarios with high causal strength. (2) The causal consistency is highly correlated with the predictive capability of the attribute classifiers (e.g., causal consistency degrades with overfitting).

Related Work
Representation Learning: The quest to develop image representations that are simultaneously robust and discriminative has led to extensive research on this topic. Amongst the earliest learning-based approaches, Turk and Pentland proposed Eigenfaces [56] that relied on principal component analysis (PCA) of data. Later on, integrated and high-dimensional spatially local features became prevalent for image recognition, notable examples include local binary patterns (LBP) [1], scale-invariant feature transform (SIFT) [40] and histogram of oriented gradients (HoG) [12]. In contrast to these hand-designed representations, the past decade has witnessed the development of end-to-end representation learning systems. Representations learned from supervised learning [19,34,53], disentangled learning [8,10,20,29,55], and most recently self-supervised learning [9,14,16,43,44] now typify modern image representations. The goal of these approaches is to learn universal representations that generalize well across arbitrary tasks. Hence, they are inclined to uncontrollably learn all contextual correlations in data. Our goal in this paper is to verify whether learned representations retain the underlying causal relations of the data generating process.
Causal Inference: Randomized controlled experiments are the gold standard of causal inference. However, in many computer vision applications, we cannot control the image formation process rendering such experiments infeasible. Concurrently, a plethora of approaches have been proposed for causal discovery purely from observational data under two main settings, full graph or pairwise. Estimating the full causal graph has been thoroughly studied, both using learning-based [2,3,6,25,28] and non-learningbased [11,27,46,52] approaches.
In this paper, we restrict our focus to causal discovery for the particular case where we have access to only two random variables at a time, both in the presence or absence of an unobserved confounder. Significant efforts have also been devoted to this problem under different scenarios. These include, comparison of information entropy for discrete variables [30,31], neural causal methods [18,37,39], comparison of noise statistics in causal and anti-causal directions [21,42], comparison of regression errors between the causal and anti-causal directions [4], comparison of Kolmogorov complexity [5,57], building classi- , Label: 0 Figure 2. All possible causal relations between pairs of random variables. A node in blue denotes cause, green denotes effect, and red denotes confounder or common effect (Z). We only consider scenarios where we observe X and Y , but not Z. As such, the graphs represent three different causal relations, (i) Label 1: causal relation (X → Y ); (ii) Label 2: anti-causal relation (X ← Y ); (iii) Label 0: X and Y are unassociated. Note that since Z is not observed, G7 is equivalent to G6 and can thus be ignored.
In this paper, the proposed NCINet is a neural causal inference method that is tailored for high-dimensional variables. It incorporates, (1) direct supervision through causal labels, indirect supervision by comparing regression errors in the causal and anti-causal direction and an adversarial loss to encourage domain generalization, and (2) in contrast to all existing approaches, our model is trained to infer causal relations from all possible (see Fig. 2) pairwise cases, including in the presence and absence of an unobserved confounder.

Causal Relations Between Representations
First, we define the primary causal inference query that this paper seeks to answer i.e., "Do learned representations respect causal relationships?". Consider the graph G 1 in Fig. 2, which has two attributes X and Y , where the causal relation between them is X → Y . An image I is generated by an unknown stochastic function of these two attributes. Let x and y be high-dimensional attribute-specific representations learned for predicting labels X and Y , respectively, from the corresponding images. The structural causal equations (SCEs) 1 that characterize this process are: where a x and a y are sampled attribute instances, is a noise variable which is independent of both X and Y and h X (·; θ X ) and h Y (·; θ Y ) are the encoders that extract the attribute-specific representations for X and Y , respectively. Under this model, given the distribution of features x ∼ 1 The SCEs and the corresponding causal inference queries for the other pairwise causal relations in Fig. 2 can be defined similarly. P (z x ) and y ∼ P (z y ) for the two attributes, we seek to determine whether the attribute-specific representations also follow the same underlying causal relations, i.e., is z x → z y ?. The association between these learned attribute features can be well approximated as a post nonlinear causal model (PNL) [64], where f 2 and f 1 are non-linear functions with f 2 being continuous and invertible, and is a noise variable such that e ⊥ ⊥ z x . The identifiability of the PNL model from observational data was established by Zhang and Hyvärinen [65]. Conceptually, the key idea is that the distribution P (z y |z x ) in the causal direction is "less complex" than that in the anti-causal direction. NCINet, the proposed causal inference approach, is designed to exploit such disparity. We note that, in the absence of strong assumptions, direct causal relation is indistinguishable from that induced by latent confounding. However, we take inspiration from the ability of humans to accurately infer causal relations only from observations in many cases, and seek to unveil causal motifs between the representations directly from samples.

Observational Causal Discovery Problem
Learning-based observational causal discovery considers a dataset S of n observational samples, where each sample S i is itself a dataset of m i representation pairs {(x 1 , y 1 ), . . . , (x mi , y mi )}, x ∈ R dx and y ∈ R dy are the learned representations corresponding to predicting X and Y respectively, and P (x, y) is the joint distribution of the two representations. The joint distribution P (X, Y ) can represent different causal relations as shown in Fig. 2, namely, (i) causal class (X → Y ); (ii) anti-causal class (X ← Y ); (iii) X and Y are unassociated, both in the absence and presence of an unobserved confounder Z.
The key idea of learning-based causal discovery is to exploit the many manifestations of causal footprints often present in real-world observational data [49]. For example, oftentimes the functional relationships in the causal direction are "simpler" than those in the anti-causal direction. Figure 3. Overview: Schematic illustration of Neural Causal Inference Net (NCINet). It comprises of, (1) a shared encoder that maps representations to a common space, (2) a supervised encoder that extracts a representation z from the common space, (3) a causal regression branch that compares the regression errors in the causal and anti-causal direction, (4) an adversary that seeks to extract the function label, and (5) a fusion module that combines information from the two branches and predicts the causal relationship. See text for more details.
Unsupervised methods exploit such causal signals either by measuring the complexity of the causal and anti-causal functions [5], the entropy of causal and anti-causal factorizations of the joint distribution [30] or comparing regression errors in the causal and anti-causal direction [4].
Going beyond a specific type of causal footprint, supervised methods seek to exploit any and all possible causal signals in the observational data by learning to directly predict causal labels from the observation dataset S. Neural causal models such as NCC [37], GNN [18] and CE-VAE [39] are a special class of supervised approaches that leverage neural networks based classifiers.
Although both supervised and unsupervised approaches are based on the same principle -namely, exploiting causal footprints -they differ in one key aspect. Unlike the unsupervised methods, the supervised approaches need ground truth causal labels to train the causal classifier. However, in most real-world scenarios the ground truth causal graph is unknown. Therefore, the supervised methods are typically trained purely on synthetically generated data and hence suffer from a synthetic-to-real domain generalization gap. Unsupervised methods on the other hand can be applied directly to the observational data of interest and hence are agnostic to the data domain. However, unlike the supervised approaches, the unsupervised methods like RECI [4] exploit only one type of causal footprint at a time, e.g., regression errors between the causal and anti-causal directions.

Neural Causal Inference Network
Neural Causal Inference Network (NCINet) is a neural causal model for observational causal discovery. Given a pair of high-dimensional attribute-specific representations S = {x j , y j } m j=1 , we seek to determine one of three causal relations, X → Y , X ← Y or X is unassociated with Y . Fig. 3 shows a pictorial overview of NCINet along with a causal data generation process that is customized for highdimensional signals.
Our entire solution is motivated from three perspectives: (1) Modeling: As described in the previous section, the supervised and unsupervised models have complementary advantages and limitations. Therefore we incorporate both of them into NCINet to make a final prediction. (2) Data: Semantic image attributes (e.g., facial features) span the whole spectrum of pairwise causal relations illustrated in Fig. 2. However, existing supervised and unsupervised learning-based causal discovery methods only consider a subset of these relations (ignoring either the independence class or the unobserved confounder) and are designed for low-dimensional signals, and therefore sub-optimal or insufficient for our purpose. Therefore, we design a synthetic data generation process for obtaining high-dimensional features spanning all possible pairwise causal relations. (3) Generalization: For NCINet to generalize from the synthetic training data to real representations we adopt two strategies. First, the synthetic feature generation process includes an ensemble of linear and non-linear causal functions. Second, we employ an adversarial loss to debias the prediction w.r.t the choice of functional classes in the synthetic training data.
NCINet comprises of five components: shared encoder, supervised encoder, causal regression branch, adversary, and classifier. These components are described below.
Encoders: There are two encoders, a shared encoder that maps the pair of representations into an intermediate repre- , and a supervised encoder that extracts features for the final classifier. The latter encoder acts on the concatenated features z x z y T and extracts a representation that is average pooled over the m samples in the representation. The resulting feature is denoted as z in Fig. 3.
Causal Regression: The Causal Regression branch of NCINet is inspired by the asymmetry idea proposed by [4], wherein the mean squared error (MSE) of prediction is smaller in the causal direction in comparison to the anti-causal direction, i.e., where C is the cause and E is the effect, φ is the regressor that minimizes the MSE when predicting E from C, and ψ is the regressor that minimizes the MSE when predicting C from E. Therefore, the causal relation can be estimated by comparing the two regression errors. An attractive property of this idea is its inherent ability to generalize to unseen causal data generating functions classes by virtue of being unsupervised and not requiring any learning.
The causal regression branch of NCINet adopt ridge regressors that operates on the intermediate embeddings , between the predictionx = z T y z y + λI −1 z y x and ground truth input x. The two regressors R X→Y and R X←Y are trained end-toend (i.e., we backpropagate through the closed-form ridge regressor solution) along with the rest of the components in NCINet. Therefore, the loss from the regression branch is, Adversarial Loss: The features z extracted from the supervised encoder potentially still contain information specific to the function class that generated the synthetic features. However, the generalization performance of NCINet may be hampered if the downstream classifier exploits any spurious correlation between the function class-specific information and the ground truth causal relations. Therefore, we measure the amount of information in z about the function class through an adversary and minimize it. This type of adversary is typically modeled as a neural network and optimized via min-max optimization, which can be unstable in practice [13,23]. For ease of optimization we instead model the adversary by a kernel ridge-regressor which admits a closed-form solutionŷ f = K (K + βI) −1 y f , where y f is the one-hot vector representing the function class of the synthetic data, β is a regularization, and K is a kernel matrix computed from the features z. The loss from the adversary which we backpropagate through is, Classifier: Finally, the supervised classifier concatenates the features z from the supervised encoder with the output T of the causal regressors, and categorizes the causal relations into three classes as follows.
We note that this is unlike existing methods for causal inference such as NCC [37], RECI [4], etc., which only categorize the causal relations into two categories, namely causal and anti-causal. However, in many practical scenarios, the image attributes and their corresponding representations could be very weak as we discuss in Section 7.2. The classifier minimizes the cross-entropy loss L C between its prediction and the ground truth causal relations l.
All the components of NCINet are trained end-to-end by simultaneously optimizing all the intermediate losses i.e., Loss = L C + L R + λL A , where λ is the weight associated with the adversarial loss. The classifier will learn to exploit all the causal footprints in the data aided by the causal regressors and the adversary. The features from the causal regressors help exploit the causal footprint corresponding to the difference in regression errors, while the adversary helps the classifier to reduce the synthetic-to-real domain generalization gap. Interaction between the regressors, adversary, and the final classifier is induced by the common intermediate representation space (z x , z y ), on which all of them operate.

Experiments: Neural Causal Inference
In this section, we evaluate the performance and generalization ability of NCINet in comparison to existing baseline methods on synthetically generated high-dimensional representations with known causal relations.
Data and Training: The lack of large-scale datasets with ground truth causal labels precludes causal discovery models from being trained on real-world observational data. Therefore, it is standard practice to train and evaluate causal discovery models on synthetic observational data. Models trained in this manner can now be applied directly to realworld observational data. Synthetic data generation typically follows the additive noise model [47], where an effect variable is obtained as a function of causal variable and perturbed with independent additive noise. We adopt the same additive noise model as our causal mechanism.
To improve generalization capability, we diversify the synthetic training data. Specifically, we adopt an ensemble of different high-dimensional causal functions including, Linear, Hadamard, Bilinear, Cubic Spline, and Neural Networks. See the supplementary material for more details. In each training epoch, we generate 1000 samples, where each data sample consists of 100 feature pairs (i.e., m = 100) by randomly sampling one of the causal functions and their respective parameters. Integrating data generation into the training process ensures that the models learn from an infinite stream of non-repeating data.
We generate the pairs of representations (x, y) via ancestral sampling. For example, in the case of G 1 where x → y, the synthetic representations are generated as follows, P (w) → P (x|w) → P (y|x, w), where w accounts for all the unobserved confounders. More details can be found in the supplementary material.
Baselines: We consider four baseline methods, ANM [21], Bivariate Fit (BFit) [24], NCC [37] and RECI [4]. These methods, however, were originally designed for causal inference on one-dimensional variables and to distinguish between causal and anti-causal directions. Therefore, we extend them to high-dimensional data, as well as to distinguish between causal direction, anti-causal direction, and no causal relation. Specifically, for NCC, we concatenate high-dimensional features x and y as the input to the network and change the output layer to three classes. For the unsupervised methods, ANM, BFit, and RECI, we regress directly on high-dimensional features x and y as required. Since these methods are score based i.e. score > 0 represents the causal direction and score < 0 represents the anti-causal direction we introduce an additional threshold to identify the no causal relation case i.e. if |score| < threshold. We use a separate validation set to determine the optimal threshold for each unsupervised method.
Generalization Results: To evaluate the performance of the models and their generalization ability, we adopt a leave-one-function out evaluation protocol. For evaluating each causal function, we train the models using data generated by all the other causal functions across all the causal graphs in Fig. 2. The results are shown in Table 1 for 8 dimensional representations. We observe that overall NCINet outperforms all the baselines.

Causal Inference on Learned Features
Our goal in this section is to estimate the causal relation between attribute-specific learned representations and verify if it is consistent with the causal relations between the corresponding labels. Furthermore, we would like to perform this analysis for all the different types of causal re-lations shown in Fig. 2. However, real-world datasets only provide a fixed collection of images and their corresponding labels, and as such do not afford any explicit control over the type and strength of causal relations between the attributes. To overcome the aforementioned limitations we consider causal inference on learned representations under two scenarios where the causal relations between the attributes are known and unknown. Datasets: We consider three image datasets with multiple multi-label attributes; (1) 3D Shapes [7] which contains 480,000 images. Each image is generated from six latent factors (floor hue, wall hue, object hue, scale, shape, and orientation) which serve as our image attributes. (2) CASIA WebFace [61] which contains 494,414 images of 10,575 classes. While the dataset does not come with attribute annotations, we annotate each image with eight multi-label attributes 2 (color of hair, visibility of eyes, type of eyewear, facial hair, whether the mouth is open, smiling or not, wearing a hat, visibility of forehead, and gender). The annotations for this dataset have been made publicly available to the research community. (3) CelebA [35] which contains 202,599 images, each of which is annotated with 40 binary attributes. However, this dataset suffers from severe class imbalance across most attributes. Experimental results on this dataset can be found in the supplementary material.
Learning Attribute-Specific Representations: We learn attribute-specific representations by learning attribute predictors for each attribute. For predicting the attributes, we use a 5-layer CNN and ResNet-18 [19] for the 3D Shapes and CASIA-WebFace datasets, respectively. The attribute predictors are optimized using AdamW [38] with a learning rate of 5 × 10 −4 and a weight decay of 5 × 10 −4 . Upon convergence of the attribute predictor training, we use the trained model to extract representations from the layer before the linear classifier at the end.
Causal Inference Baselines: To infer the causal relations between the learned attribute representations we apply NCINet and two other baselines NCC and RECI. Both NCINet and NCC are trained on the synthetic dataset as described in Section 6.

Known Causal Relations Between Labels
In this experiment, we resample the datasets to obtain samples with the desired type of causal relations. Consequently, in this scenario, the causal relationship between the attribute labels is known, and we seek to verify if the corresponding attribute-specific learned representations also satisfy the same causal relations. We note that, although the data generated in this way will not reflect the true underlying causal relations between the attributes, it nonetheless al-

Generating Images with Causally Associated Attributes:
The data sampling process proceeds in two phases. In the first phase, we generate the attribute labels with known causal relations. We represent each type of causal graph via its corresponding Bayesian Network with hand-designed conditional probability tables. Then we sample batches of labels with known causal relations through Gibbs Sampling. To further ensure that the sampled labels correspond to the desired causal relation, we measure the strength of their causal relation through an entropic causal inference method [30]. In the second phase, we sample images that conform to the sampled attribute labels. On the 3D Shapes dataset, to increase the diversity of the images and ensure that the representation learning task is sufficiently challenging, the images are corrupted with one of three types of noise, Gaussian, Shot, or Impulse.
Results: To measure the consistency between the causal relations of the labels and the causal relations of the respective representations, we introduce a new metric dubbed causal consistency. For a given set of learned representations (x j , y j ) m j=1 , we split it into multiple non-overlapping subsets. The causal relation is estimated for each subset and we measure how many of them are consistent with the causal relation l between the labels. Evaluating over multiple subsets serves to prevent outliers from severely affecting the causal inference estimates (see supplementary material for more details). Fig. 4 shows the causal consistency results across the different types of causal relations. We make the following observations: (1) In most cases, across both 3D Shapes and CASIA-WebFace, the causal relationship between the learned representations is highly consistent with that of the labels. This empirical evidence is encouraging since it suggests that representation learning algorithms are capable of mimicking the causal relations inherent to the training data. (2) In the controlled setting of this experiment, among the three causal inference methods, NCINet appears to provide more stable and consistent estimates of causal relations across the different causal graphs and datasets, followed by RECI and NCC.

Unknown Causal Relations Between Labels
In this experiment, we consider the original CASIA-WebFace dataset as is, without any controlled sampling. We choose smiling or not and visibility of eyes as the two attributes to investigate. The attribute predictors are trained/validated on 10,000/10,000 randomly sampled images using a ResNet-18 architecture. Other training details are similar to the experiment in Section 7.1. Since the true causal relation between the labels is unknown, we use an entropic causal inference method [30] to estimate it. While the causal relation between the labels suggests that smiling has an effect on the visibility of eyes its causal strength is very weak (0.23/0.20 for training/validation). The causal relation between the learned representations follow the same trend, with around 20% of the representation subsets agreeing with smiling having an effect on the visibility of eyes, while 80% of them suggest that there is no causal relation between the two attributes.

Discussion
This section analyzes the effect of various aspects of representation learning on the causal consistency between the learned representations and the labels.

Effect of Adversarial Debiasing on NCINet:
We study the contribution of adversarial loss L A on the generalization performance of NCINet. Table 2 reports the causal inference results on the synthetically generated representations in Section 6. Overall the adversarial loss aids in improving the generalization ability of NCINet, thereby validating our hypothesis that the features z from the supervised encoder still contains information specific to the function class. Effect of Training Epochs: Here we study the causal relations between the representations as a function of the training epochs. In this experiment, we test the causal consistencies of features extracted by models from each training epoch, and show the average value of every 10 epochs. We hypothesize that as the attribute prediction performance of the representations improves, the causal relation between the representations will also become more consistent with the causal relation between the labels. Fig. 5 shows the causal consistency as a function of the training epochs. We make three observations: (1) as training progresses, the causal consistency of NCINet improves and remains stable which is consistent with our hypothesis. (2) Although RECI fails on G 1 and G 2 , it follows the same trend in the other cases. (3) NCC is prone to failure in no causal relation data.
Effect of Overfitting: Here we study the effect of overfitting on the causal consistency between the representations. We hypothesize that as the representation learning process overfits, the causal consistency on the validation features will drop. Fig. 6 shows the results of this experiment. We observe that after overfitting, the causal consistency drops for features from both the training and test set. However, the former still retain some causal consistency.

Conclusion
This paper sought to answer the following questions: Do learned attribute-specific representations also satisfy the same underlying causal relations? And, if so, to what extent? To answer these questions, we designed Neural Causal Inference Network (NCINet) for causal discovery from high-dimensional representations. By bringing together ideas from learning-based supervised, unsupervised causal prediction methods and adversarial debiasing, NCINet exhibits significantly better causal inference generalization performance. We applied NCINet to estimate the causal consistency between learned representations and the underlying labels in two scenarios, one where the causal relations are known through controlled sampling, and the other where the causal relationships are unknown. Furthermore, we analyzed the effect of overfitting and training epochs on the causal consistency. Our experimental results suggest that learned attribute-specific representations indeed satisfy the same causal relations between the corresponding attribute labels under controlled scenarios and with high causal strength.
Causal analysis of learned representations is a novel, challenging, and important task. Our work presents a solid yet preliminary effort at answering the questions raised in this paper. Our work is limited from the perspective that there exist many potentially interesting and related aspects of this problem that we did not explore here. From a technical perspective, we foresee two limitations of our work. (1) Unlike the unsupervised methods like RECI, NCINet needs to be retrained if the dimensionality of the representation changes. (2) NCINet and the baselines exhibit poor causal inference performance on data with weak causal relations. As the causal relation gets weaker, it is increasingly difficult to distinguish it from the no causal association case. Furthermore, our data generating process does not afford explicit control over the causal strength.

Supplementary Material
In this supplementary material, we include, 1. Precise description and definition of causal consistency in Section 9 2. Experimental results of causal consistency on CelebA Face Dataset in Section 9.
3. An ablation experiment on effect of the adversarial loss on the performance of NCINet in Section 9.
4. Additional experimental results analyzing the effect of factors such as representation dimensionality and network architecture for learning the representations on causal consistency in Section 9.
5. Details of the process for generating the synthetic representation for training NCINet and the baselines in Section 9.
6. Details of the process for generating images with causally associated attributes in Section 9.
7. Details of facial attribute annotation on the CASIA dataset used for our experiments in Section 9.

Definition of causal consistency
Datasets are divided into subsets. Causal consistency is the ratio of subsets whose causal relation between representations matches that of the labels, with higher values representing higher consistency. Further, we compute average causal consistency (and confidence intervals) across a small interval K (ten) of epochs after representation learning has converged. Overall, Causal consistency =

Causal consistency of CelebA
We also conduct causal inference on representations learned on the CelebA dataset. Specifically, we experiment on the case where causal relations between labels are unknown. Similar to the experiments on the CASIA dataset, we chose smiling and narrow eyes as the two attributes to investigate, train and validate the attribute predictors on 10,000/10,000 randomly sampled images using a ResNet-18 architecture. We also apply the entropic causal inference method [30] to estimate the causal relation between labels and finding that smiling is a cause of narrow eyes. Table 3 shows the causal inference results of NCINet and two baseline. NCINet exhibits strong causal consistency in the correct causal direction. Due to the challenge of selecting a score threshold (see Section 6 of main paper for details) for RECI that generalizes beyond the training data, it classifies all sample as no causal relation. However, if we set the threshold to 0 and let RECI only infer causal and anti-causal direction, the majority samples will also be inferred as the same directions with labels, which shows that in this case, the causal relation between the features is indeed consistent with that of the labels.  To investigate how adversarial loss contributes to NCINet, we test three different λ values in Loss = L C + L R + λL A and present their generalization results on highdimensional synthetic data . Table 4 shows the generalization results of using different adversarial weight. The results indicate that for data generated from different causal functions, the optimal weight λ is different. However, even a small weight of ARL loss could help the model's generalization ability. Figure 7 shows different components of training loss. With a wight λ associated with the adversarial loss, all losses are roughly of the same order of magnitude and well balanced.

Discussion
Effect of Representation Dimensionality: To investigate the effect of representation dimensionality on the inherent causal relations, we evaluate causal consistency across different representation dimensionalities on the CASIA WebFace dataset. We set different number of dimensions for the layer before the last linear classifier in the attribute predictor, and extract representations from models that are trained to convergence. Figure 8 shows the causal consistency. We observe that there is slight degradation in the causal consistency as the number of dimensions increases, especially at 128 dimensions. However, a more careful and controlled experiment is necessary in order to gain a deeper understanding on the role of representation dimensionality on causal consistency.

Effect of Architecture :
Here we seek to understand if the network architecture has an effect on the causal relations between learned attributes. Therefore, we use four different architecture, including ResNet18, ResNet34, ResNet50 and WideResNet as the attribute predictor for Casia Dataset. Figure 9 shows the causal consistency for multiple network architectures. The results indicates that changes in network architecture have a larger impact on G 1 and G 2 , while providing more stable results on other graphs.

Effect of Sample Complexity :
We also study the effect of sample complexity. We set different sample size m and verify the generalization performance. As shown in Table  5, as sample size increases the results generalize better but plateau with a certain size of sample complexity. The results indicates that to infer the causal relation an adequate number of pairs are needed for each sample.
Results of Multiple Runs: To evaluate the stability and effectiveness of different methods, we run all baselines for five times in the leave-one-function-out generalization experiment, and present their mean accuracy and standard deviation. Specifically, in each run, we generate five different testing datasets for each causal function. The results, shown in Table 6, indicate that NCINet have a more stable result comparing with other baselines.
Standard Deviation: Table 7a and 7b show mean and standard deviation (specific numbers of Figure 4 in main paper) over the small interval of epochs after representation learning has converged on the 3d shape and Casia datasets. As can be observed that causal consistency of NCINet, from one epoch to the other is very stable, which is comparable to unsupervised method.

Synthetic Causal Representation Generating Process
The following steps are the detailed data generation process. In this illustration, we taking the case of X being the cause variable for example: • Generating initial cause data: we first sample initial data W from a mixture of Gaussian distributions, and then generate synthetic representation X through a causal function: X = f (W ) + .
• Generating ground truth label: Randomly select one of the first six scenarios in Figure 2 of main paper, and assign the corresponding label to l.
The five high-dimensional causal functions are specified in Table 8, with both w/o confounder and w/ confounder cases. For linear and quadratic functions, we directly multiply the cause variable with coefficient matrices in their form. For Bilinear function, we apply a bilinear transformation to the cause variable. For cubic spline function, we follow [37], applying a cubic Hermite spline function. We draw k knots from N (0, 1), where k is drawn from Ran-domInteger (5,20). For Neural Networks function, we apply multilayer perceptrons with hidden layers and numbers of hidden neurons drawn from RandomInteger(0, 3) and Ran-domInteger (8,20). For each function, its parameters (e.g., A, B or MLP weights) are drawn at random from N (0, 1) for each data sample. The noise terms are sampled from Gaussian(0, v), where v ∼ Uniform(0, 0.1). After each operation, including data initialization and causal relation establishment, the data will be normalized to zero mean and unit variance. Note that for initial data generating, we also apply same causal function as high-dimensional causal relation generating.

Generating Images with Causally Associated Attributes
As mentioned in Section 7 of the main paper, the image generating process contains two phases. In the first phases, we sample labels with six causal relations of Figure 2 in main paper. We first build Bayesian Network with hand-designed conditional probability tables of six causal graphs, and then conduct Gibbs Sampling to get attribute labels with known causal relation. The goal of the second phase is to sample images using the labels with known causal relation. For example, in 3D Shapes Dataset, we select attribute floor hue and wall hue as the attribute X and Y in six causal graphs. Then we sample images according to the labels with known causal relations, that is, we select images whose attribute floor hue and wall hue are same with the sampled labels, while we keep other attributes random. For each image, we also randomly add one of three types of noise, Gaussian, Shot, or Impulse. Figure 10 shows examples of images generated from the 3D Shapes dataset. Similarly for facial dataset CelebA and Casia Dataset, we also apply same strategy to sample images using labels with known causal relationship from original dataset. π k N (µ k , Σ k ) and x = g x (w) + y = Ax + y = A(x x) + Bx + y = x T Ax + y = Spline(x) + y = M LP (x) + w/ Confounder w ∼ K k=1 π k N (µ k , Σ k ) z = g z (w) + x = g x (z) + y = Az + y = A(z z) + Bz + y =z T Az + y = Spline(x) + Spline(z) + y = M LP (z) + z indicates concatenation of x and z. Figure 10. Sample images generated from the 3D Shapes dataset with known causal relations.

Facial Attribute Annotations
Progress in causal discovery methods for computer vision has been hampered by the lack of a large-scale dataset annotated with different underlying causal relations. We posit that existing datasets such as CelebA [35], which has annotations of multi-label attributes in the form of binary labels, is inadequate for causal discovery for a couple of reasons. First, a majority of the images for each attribute are highly imbalanced towards one of the two classes. And more importantly, we observed that a majority of the binary labels are very close to being independent of each other. As such, it may not accurately reflect the causal relations in the real-world and are for the most part are unsuitable as an evaluation benchmark.
To overcome this hurdle we adopt the CASIA-Webface [61] dataset, a large public face dataset with 10,575 people and 494,414 images in total, for our experiments. Since this dataset is designed for face verification and recognition problems, only identity annotation is available. Therefore, we augment this dataset with manual annotations of multiple facial attributes (see Table 9 for details). The annotated attributes 3 include: color of hair, visibility of eyes, type of eye wear, facial hair, whether mouth is open, smiling or not, wearing a hat, visibility of forehead, and gender. The annotations for this dataset will be made publicly available to the research community. 4 3 The choice of attributes and labels for each may arguably still not fully reflect the real-world. Nonetheless, we believe this dataset could be a valuable resource for causal analysis task. 4 The onus of obtaining the actual images will still remain with the respective research groups.
The attributes were chosen to be objectively as unambiguous as possible while spanning a range of semantic properties with a variety of causal relationships amongst them as shown in Figure 1 of main paper. For example, smiling could be a cause of mouth being open because smiling might result in an open mouth. Or, wearing a hat could be a cause for affecting the visibility of forehead, since hats may cause occlusions on people's forehead. Moreover, gender could also causally affect facial hair, because females do not have facial hair in most cases.

Gradient of Closed-Form Solution
In order to find the gradient of the kernel ridge regressor of adversary, we rewrite the loss function of adversary as: Then from [17], letting θ be arbitrary scalar element of encoder, we have where K ⊥ is the orthogonal complement of K, and  a hat  Gender   red  12,337  closed  18,047  none  424,128  none  364,076  partially visible 126,219  open  215,556  no  221,170  no  424,659  female 209,402  gray  17,050  open  425,185  eyeglasses 17,805  beard  1,763  visible  297,555  wide open 16,717  yes 231,890  yes 28,401  male  243,658  bald  13,239  not visible 9,828  sunglasses 11,127  mustache  21,525  fully blocked  29,286  closed  220,787  blonde  85,848  goatee  2,613  black  158,761  beard and mustache  48,025  brown  144,523  mustache and goatee 15,058  not visible 21,302   Equation 8 can be directly used to obtain the gradient of objective function in 7. The gradient of ridge regressor from unsupervised branch can be derived in same way by simply replacing the kernel matrix K with linear one.