Introduction
Deep Neural Networks (DNNs) have achieved remarkable success in various domains, yet they remain susceptible to "shortcut learning." This phenomenon occurs when models rely on spurious correlations—such as background color or environmental context—rather than the invariant features of the target object. Consequently, these models often fail when deployed in environments where these correlations no longer hold, a challenge known as dataset shift caused by selection bias.
Methodology: Post-Hoc Causal Adjustment
The core contribution of this work is a simple, post-hoc method to "deconfound" feature representations without retraining the entire model. The approach leverages the observation that the final layers of a DNN, particularly those preceding a softmax output, are mathematically linear. By extracting these high-level features, we can apply causal tools that were originally designed for simpler linear models.
The proposed algorithm follows four primary steps:
- Feature Extraction: Activations are extracted from the final hidden layer ($X$) of a pre-trained DNN.
- Linear Deconfounding: Linear regression is used to model the influence of the confounder ($C$) and the label ($Y$) on these features.
- Counterfactual Shift: The influence of the confounder is mathematically subtracted to create "counterfactual features" ($X^*$). This represents what the feature would look like in a neutral environment.
- Linear Classification: A simple classifier (e.g., logistic regression) is trained on these cleaned features.
Causal Framework
The theoretical foundation of this method rests on causal modeling. By representing the relationships between features, labels, and confounders as Directed Acyclic Graphs (DAGs), we can identify how selection bias ($S$) distorts the learned representations in both training and testing phases.
As shown in the causal diagrams, the features $X$ are influenced by both the true label $Y$ and the confounder $C$. In the training set, selection bias $S$ creates a spurious correlation between $C$ and $Y$. The counterfactual adjustment aims to break this link, ensuring the classifier relies solely on the causal path from $Y$ to $X$. Crucially, this method deconfounds the features at inference time, providing stability even when the test environment differs from the training environment.
Experimental Results
The method was validated using a "Colored MNIST" dataset, where digit color served as a strong confounder in the training set (e.g., digits 0-4 were 99% green). While a standard DNN's accuracy dropped significantly (from 99% to 85%) when the color-digit correlation was reversed in the test set, the proposed counterfactual adjustment maintained a stable accuracy of approximately 97% across all levels of dataset shift.
Furthermore, the method outperformed traditional data-balancing techniques like SMOTE. Statistical tests using partial correlations confirmed that the adjusted features $X^*$ were independent of the confounder $C$ given the label $Y$, indicating successful removal of the biased shortcuts.
Discussion and Limitations
This post-hoc adjustment offers a lightweight and flexible wrapper for existing large-scale models. However, it requires that confounders be explicitly observed and labeled in the dataset. Future research should address scenarios with latent (hidden) confounders and explore the application of these linear causal tools to more complex, high-dimensional environmental biases in natural images.
Summary updated