Monitoring Shortcut Learning using Mutual Information
Abstract
The failure of deep neural networks to generalize to out-of-distribution data is a well-known problem and raises concerns about the deployment of trained networks in safety-critical domains such as healthcare, ﬁnance and autonomous vehicles.
We study a particular kind of distribution shift — shortcuts or spurious correlations in the training data.
Shortcut learning is often only exposed when models are evaluated on real-world data that does not contain the same spurious correlations, posing a serious dilemma for AI practitioners to properly assess the effectiveness of a trained model for real-world applications.
In this work, we propose to use the mutual information (MI) between the learned representation and the input as a metric to ﬁnd where in training the network latches onto shortcuts.
Experiments demonstrate that MI can be used as a domain-agnostic metric for monitoring shortcut learning.
1. Introduction
Our understanding of ‘how’ and ‘what’ neural networks learn is limited, which raises concern about the deployment of neural networks in safety-critical domains.
Despite achieving state-of-the-art performance on benchmark datasets, neural networks may fail to generalize in realworld settings or for out-of-distribution data (Koh et al., 2021).
For example, models trained for cancer detection may not generalize on data from a new hospital (Castro et al., 2020;
Perone et al., 2018; AlBadawy et al., 2018) and self-driving cars may not generalize to new lighting conditions or object poses (Alcorn et al., 2018; Dai & Van Gool, 2018).
One reason why models may fail in real-world Correspondence to: Mohammed Adnan < madnan01@uoguelph.ca > , Graham Taylor < gwtaylor settings could be attributed to learning shortcuts (Geirhos et al., 2020) from the training data.
A shortcut is a type of distribution shift where spurious correlations exist only in the training data, resulting in the learning of non-intended or easy-to-learn discriminatory features which work well on the training and test dataset but not on out-of-distribution real-world datasets (Wiles et al., 2022; Geirhos et al., 2020).
Shortcuts can arise due to dataset biases or the model using ‘trivial’ or unintended features like high-frequency noise patterns or the image background for the classiﬁcation task.
For example, an Inception-V3 model trained to detect hip fractures was found to use scanner information for learning discriminatory features (Badgeley et al., 2019); deep learning systems trained to detect COVID-19 from chest radiographs can rely on confounding factors (shortcuts) rather than medical pathology (DeGrave et al., 2021).
While our understanding of shortcuts and how they arise is still developing, a helpful tool to practitioners deploying machine learning models in safety-critical domains with a high cost of failure would be to monitor shortcuts during the training phase.
Although the phenomenon of shortcut learning is widely known, there is no effective method available to monitor shortcuts being learned.
Interpretable machine-learning methods such as feature attribution, GradCAM (Selvaraju et al., 2017), and LIME (Ribeiro et al., 2016) have been used to understand a model’s dependency on spurious correlations.
However, it has been shown that such post-hoc explanations are ineffective (Adebayo et al., 2021;
Alqaraawi et al., 2020; Chu et al., 2020).
In this work, we show that shortcut learning can be understood using the information bottleneck framework (Tishby et al., 1999; Tishby & Zaslavsky, 2015), by using the mutual information (MI) between the inputs and the learned representation to monitor shortcut learning.
We use the neural tangent kernel (NTK)
(Jacot et al., 2018) to study the training evolution of shortcut learning.
We design experiments using synthetic and complex real-world data to demonstrate the relationship between (MI) and shortcut learning, and show that MI can be used as a metric for domain-agnostic assessment of shortcuts.
We ﬁnd that compression as measured by MI is associated with the tendency to learn shortcuts. a r X i v : . 13034v [ c s .
L G ] J un 2. Background
Shortcut learning: Wiles et al.
(2022) deﬁned shortcuts or spurious correlations as a type of distribution shift such that two or more attributes are correlated at training time, but not for the test data, where they are independent.
In a more general sense, shortcuts are easy-to-learn decision rules that can be exploited in the absence of distribution shift (i.e. on standard benchmarks) but fail to transfer to more challenging and diverse testing conditions, such as real-world datasets (Geirhos et al., 2020).
Information bottleneck method: The information bottleneck (IB) can be viewed as a rate-distortion problem cast entirely in terms of mutual information (MI)—denoted “ I ( V ; Z ) = I ( Z ; V ) ”
(Tishby et al., 1999).
A distortion function measures how well a relevant variable V is predicted from another variable Z , where Z is usually a compressed representation of the input X .
The rate refers to the complexity of Z , which is less than or equal to X .
IB is a general method for data compression but has been advanced as an explanatory tool predictive of learning and generalization of neural networks (NNs).
It has been suggested that NNs trained by SGD may learn compressed representations Z of their input, making them insensitive to data idiosyncrasies, yet maintain sufﬁcient relevant information for predicting the output Y (e.g. class labels)
(Tishby & Zaslavsky, 2015; Shwartz-Ziv & Tishby, 2017).
This trade-off between compression and preserving task relevant information is optimized by the notion of “minimal sufﬁcient statistics” (Cover & Thomas, 1991).
The IB view suggests that NNs trained by cross-entropy loss may implicitly minimize the following Lagrangian:
[Equation]
enabling them to implement minimal sufﬁcient statistics for different β -constraints on the error.
Neural tangent kernel: Distribution-free estimation of
MI for high-dimensional data is challenging and often intractable.
One workaround to this problem is using an inﬁnite ensemble of inﬁnite-width neural networks (ShwartzZiv & Alemi, 2020) which confer tractable bounds on MI.
The neural tangent kernel (NTK) (Jacot et al., 2018) is a kernel that describes the evolution of inﬁnite-width neural networks during their training by gradient descent, thus allowing the systematic study of neural networks using tools from kernel methods.
Inﬁnite-width neural networks behave as linear functions, and their training evolution can be fully described by the NTK.
Shwartz-Ziv & Alemi (2020) used [Figure] the fact that the output of an inﬁnite ensemble of inﬁnitelywide neural networks initialized with Gaussian weights and biases and trained by MSE loss is a conditional Gaussian distribution.
This allows tractable computation of (MI) between the representation Z and the targets Y : I ( Z ; Y ) , and the MI between Z and the inputs X during training: I ( X ; Z ) .
3. Shortcuts and information bottleneck
Our hypothesis is that MI as measured during the evolution of a network’s parameters can be used to monitor shortcut learning as it occurs.
Shortcuts allow networks to learn a maximally compressed representation Z , i.e., I ( X ; Z ) is considerably reduced and thus can be used as a metric to monitor exploitation of shortcuts.
To support our hypothesis, we design controlled datasets containing spurious correlations and measure I ( X ; Z ) during the training evolution using the NTK.
Using insights from the concept of a previously introduced “mutual information plane” (Shwartz-Ziv & Tishby, 2017), we can observe shortcut learning as it happens and ﬁnd the time where the network stops exploring the preferred (generalizable) solution space and latches onto the spurious signal.
4. Experiments and observations
Experimental Setup: For each experiment, we plot
I ( X ; Z ) and I ( Z ; Y ) w.r.t.
time, generalization error/loss on clean data (without spurious correlations), and the information plane ( I ( Z ; Y ) vs. I ( X ; Z ) ).
Note that we calculate the upper bound of I ( X ; Z ) , and are only interested in the training dynamics rather than the precise value of MI.
MNIST with synthetic shortcut: We train a model to classify MNIST images into odd and even digits.
We add a small white patch on one corner of all even digits of the MNIST training dataset as a spurious correlation (Figure 1).
The network can use the patch to accurately classify the images into odd and even.
We compare the MI during the training evolution on datasets with and without shortcuts. [Figure] with shortcut
[Figure] In Figure 2a and Figure 2c [Figure] we observe that the mutual information I ( X ; Z ) increases initially during training but then latches onto the shortcuts, after which the mutual information decreases sharply.
It can also be observed in Figure 2b that generalization error increases after the point at which
MI starts to decrease, indicating that the network explores the more optimal region of the solution space in the initial training epochs before discovering shortcuts.
This is consistent with the ﬁndings of Schwartz-Ziv and Tishby (2017) about the behaviour of SGD.
In the initial phase, SGD explores the multidimensional space of solutions.
When it begins converging, it arrives at the diffusion phase in which the network learns to compress (Shwartz-Ziv & Tishby, 2017).
In both settings, the model achieves high training accuracy, i.e., I ( Z ; Y ) (Figure 2d) but the difference in test set loss is striking (Figure 2b).
Visualisation: To visually verify that the network is learning the shortcut in the above experiment, we generate a saliency map.
We use the ﬁnite-difference estimation to ﬁnd the gradient of the class probability w.r.t.
to the input pixels.
The network predominantly uses the shortcut in the image to predict the class (Figure 3). [Figure]
Effect of partially correlated shortcuts:
In real-world data, shortcuts are often partially correlated with the output, i.e., the model cannot classify with 100% accuracy using only the shortcuts.
To understand the effect of partially correlated shortcuts on the training dynamics, we construct different datasets with varying degrees of shortcut efﬁcacy.
Instead of corrupting all the even images, we add a small white patch on one corner only to a speciﬁc percentage (50%–100%) of even images.
We plot the MI for varying degrees of corruption in Figure 4 for 1000 training points sampled uniformly.
We observe that as the effectiveness of the shortcut increases,
I ( X ; Z ) converges to a lower value indicating the ability to perform more compression.
We also note an interesting behaviour during the training evolution: when the shortcut is partially correlated, MI does not decrease signiﬁcantly as compared to the 100% effective shortcut.
We speculate that, while in these cases (e.g. 80–90% shortcut efﬁcacy) the model is able to recover some generalization ability, its ability to discover high generalization solutions is irrevocably deteriorated once it discovers the minima corresponding to the shortcut solution.
CelebA with natural shortcuts: We also test our hypothesis on a dataset containing natural shortcuts.
We curate images from the CelebA dataset such that all images tagged as male have the “black hair color” attribute, while images tagged as female have the “blonde hair color” attribute.
We train the network to classify facial images into the male and female categories 2 , while the network may use hair color as a shortcut for accurately classifying the images.
Since the dataset is not controlled, some images from both classes have a black color in different parts of the image (background, clothes, etc.), reducing the effectiveness of the hair color attribute.
We plot the MI trajectory with and without [Figure] shortcuts for 100 sample training points sampled uniformly in log scale (Figure 5).
We observe MI proﬁle similar to
Figure 4.
On data without the shortcut, MI increases consistently, while in the presence of shortcuts, MI converges to a lower value, therefore validating our hypothesis on real-world data with natural shortcuts.
Effect of shortcut on the loss landscape: We visualize the loss landscape of neural networks to understand the effect of shortcuts on the optimization trajectory.
We plot loss along a linear path connecting the initial parameter θ o and converged parameter θ ∗ in the weight space (Goodfellow et al., 2014) and polar coordinates ( r t , φ t ) plot measuring the deviation from the linear line between θ i and θ ∗ (Figure 6).
We parameterize the line with α such that θ = (1 − α )
θ i + αθ ∗ .
Polar coordinates can be calculated using r t = ||(cid:52) θ t || ||(cid:52) θ
o || and φ t = arccos (cid:52) θ t ×(cid:52) θ o ||(cid:52) θ t ||×||(cid:52)
θ o || , where (cid:52) θ t = θ t − θ ∗ . We observe that the loss landscape around θ ∗ in the case of shortcuts is surprisingly ﬂat as compared to the valley-like shape for a model trained on data not containing shortcuts using the MNIST dataset.
The polar plot shows that the optimizer deviates less from the linear trajectory when trained with shortcuts. [Figure]
5. Conclusion and future work
In this work, we sought to understand why networks tend to to learn shortcuts through the lens of the information bottleneck method.
We showed that mutual information can be used to monitor training dynamics w.r [Figure] t. shortcut learning without using any domain knowledge; this is an advantage compared to methods adapted by the interpretable ML literature, where domain knowledge is required.
However, we used the NTK to estimate mutual information, limiting our
[Figure]
approach to inﬁnite-width neural networks.
In the future, we will address this limitation and develop methods to avoid shortcut learning using tractable MI estimators that place less severe constraints on the model architecture (Selby et al., 2022; Gabri´e et al., 2018).
We are also interested in exploring the relationship between the curvature of the solution minima and shortcut learning.