Frequency Shortcut Learning in Neural Networks
Abstract
The generalization of neural networks is harmed by shortcut learning: the use of simple non-semantic features may prevent the networks from learning deeper semantic and task-related cues.
Existing studies focus mainly on explicit shortcuts, e.g. color patches and annotated text in images, that are visually detectable and may be removed.
However, there exist implicit shortcuts determined by bias or superficial statistics in the data that neural networks can easily exploit.
Mitigating the learning of implicit shortcuts is challenging due to the simplicity-bias and an intrinsic difficulty in identifying them.
We empirically investigate shortcut learning in the frequency domain and propose a method to identify learned frequency shortcuts based on frequency removal.
We found that frequency shortcuts often correspond to textures consisting of specific frequencies.
We also investigate the influence of frequency shortcuts in Out-of-Distribution (OOD) tests.
Introduction
In classification, shortcuts are decision rules specific for a dataset, based on spurious correlations between data and ground truth, rather than on the correlation of semantic and task-related cues [1].
The training of NNs is affected by a biased learning behavior known as simplicity-bias, inducing the networks to learn simple but effective patterns, known as shortcuts, disregarding semantics related to the problem at hand [2].
For instance, in regression tasks, the networks are biased towards lowfrequency components during learning [3] and favor fitting input data to a low-frequency function [4], because low frequencies carry most of the needed information to reconstruct signals and are easier to learn [5].
To improve the generalization and robustness of NNs, researchers investigate methods to mitigate shortcut learning.
Most of them focus on shortcuts that are explicitly observable [6, 7] which are used to augment other classes, thus reducing their discriminative power.
However, data can contain implicit shortcuts that are not always observable, e.g. spurious texture [8] or superficial statistics [9], which contribute to high performance on IID datasets but hamper generalization to
OOD datasets.
These are more difficult to identify.
Shortcut learning [1] is caused by a simplicity-bias of NNs [2].
Models trained for regression tasks tend to learn low-frequency components [3].
Classification models, instead, tend to learn spurious correlations between input images and ground truth labels to achieve classification with the least effort, e.g. a text manually embedded in images of a certain class [10], which the network uses as the most discriminant feature for classification.
The presence of the text in images of other classes as well as the absence of the text in those of the intended class lead to incorrect predictions.
Avoiding shortcut learning is a promising way to improve the generalization of NNs.
In [6], the authors identify the shortcuts for a class and embed them in another class during training.
Identifying implicit shortcuts in the training data is much more difficult than identifying explicit visible shortcuts.
Regularization was used to decouple feature learning dynamics, forcing NNs to learn from more features instead of a subset of shortcut features [11].
In [12], the authors evaluate a shortcut degree of learned features, inspecting the gradient at early stage and at the end of the training.
An auxiliary network with low capacity was applied to measure the shortcut degree of images in [7].
Implicit
Feature Modification with adversarial perturbations was proposed to reduce learning shortcut features in contrastive learning [13].
The focus on mitigation of shortcut learning in image classification is limited to synthetic and visible shortcuts, rather than those implicitly present in the data [6, 7].
In this work, we empirically investigate shortcut learning in classification from a Fourier perspective, and show that simplicity-biased learning results in frequency-biased learning.
NNs can reach their objective by finding implicit shortcut solutions in the Fourier domain, which we can identify with an iterative method based on the evaluation of the contribution of single frequencies to classification.
We show that the identified shortcuts directly reveal the texture-bias of NNs.
Identifying frequency shortcuts
Require:
Test model M , Dataset D , Exploration class c , Predefined margin m , Frequency set ranked by importance R ,
Ensure: Dominant frequency map M c of class c for ( u,v ) in R do
M c [ u,v ] = 1 end for for ( u,v ) in R do Prediction correct =for X j ,L j in D c do
F ′ ( X j ) =
F ( X j ) − ( u,v )
X ′ j = F − 1 ( F ′ ( X j ))
Y predict =
M ( X ′ j ) if Y predict =
L j then
Prediction correct + = 1 end if end for if Prediction correct > =
Prediction best − m then ▷ Margin controls performance degradation
M c [ u,v ] =
Prediction best =
Prediction correct ▷ Threshold is updated if a frequency is removed end if end for
We investigate shortcut learning in the Fourier domain by an iterative method (see Algorithm 1) that evaluates the contribution of frequencies to classification results.
In each iteration, the contribution of a single frequency is evaluated by measuring the performance degradation on the classification results induced by filtering it out from the test images.
If no reduction of accuracy is observed when removing a certain frequency, then this frequency is discarded from subsequent iterations.
If the degradation is above a certain threshold, the specific frequency is deemed relevant.
The threshold is dynamically updated based on the predictions after a frequency is removed.
We do not use a fixed threshold as removing low frequencies may already reach the threshold, and subsequently, all high frequencies are retained, and thus every frequency removed early is considered unimportant.
We use a margin m to control performance degradation and decrease the comparison threshold.
The higher the value of m , the easier the frequencies are removed and thus more degradation of performance is allowed.
The final outcome is a dominant frequency map (DFM), which shows the frequencies contributing the most to the classification of a specific class.
Our hypothesis for frequency shortcut is that a small set of frequencies cannot represent properly task-related features, such as object shape.
Thus, a DFM containing few frequencies that guarantee high classification performance is an indication of a learned frequency shortcut.
Experiment setup.
We train different models (several ResNet and VGG configurations) on the
CIFAR-10 dataset [14].
We inspect the trained models and the relevance of the frequency components learned during training for classification using Algorithm 1 with different values of m to generate class-wise DFMs.
Then, we filter the images of each class using the DFMs (in Fig. 1a) as masks in the Fourier domain to retain only the dominant frequencies, and compare the classification performance on the filtered images with that obtained when using the original images.
We measure the performance degradation as ∆ =
( acc ( D O ) − acc ( D F )) /acc
( D O ) , where acc ( D O ) is the accuracy on the original test set and acc ( D F ) is the accuracy on the test images filtered with the DFMs.
With the resulting maps, the models can maintain roughly 70% of the prediction performance, compared to the performance on the original images.
We evaluate how frequency shortcuts affect the generalization of models on OOD datasets, by testing on the ImageNet-10 dataset [15], a subset of
ImageNet with similar characteristics as CIFAR-10.
We apply the (inverse) DFMs to generate test sets with contributing frequencies only or without them.
Class-wise frequency shortcuts result in texture-biased classification.
In Fig.
1a and Fig.
A.1, we show the DFMs obtained for different architectures for each class in the CIFAR-10 dataset.
We observed that, for instance, the maps of dominant frequency learned by ResNet-18 for the classes ‘deer’ and ‘frog’ contain less than 20% of all frequencies.
However, about 80% of the samples of these two classes are predicted correctly despite the limited amount of frequency information.
R e s N e tairplane automobile bird cat deer dog frog horse ship truck
R e s N e t
R e s N e t(a) airplane automobilebirdcatdeerdogfroghorseshiptruck P r e d i
c t i o n s
Map of deer a i r p l a n e a u t o m o b il e b i r d c a t d ee r d o g f r o g h
o r s e s h
i p t
r u c k
Ground truth airplane automobilebirdcatdeerdogfroghorseshiptruck P r e d i c t i o n s
Map of frog      (
[Figure] [Figure]
In Fig.
2, example images from the class ‘frog’ and ‘dog’, correctly classified, are shown.
Filtering these images using the DFM of the class ‘frog’ results in only-texture images, which are both classified as ‘frog’.
This indicates a bias of the classifier that associates the class ‘frog’ with certain texture patterns which we can identify using our Algorithm 1.
The very specific texture patterns used for classification are not clearly visible by observing the original images or not directly associated with task-related semantic cues of the object to recognize.
We filter the test images from CIFARusing the DFMs of the class ‘deer’ and ‘frog’, and report the test results in the confusion matrices in Fig.
1b.
They highlight a classification bias towards the classes concerned, indicating a misuse of specific sets of frequency as discriminative features to recognize samples from these classes.
The dependency on specific frequency patterns to achieve classification is in line with the observation
How do frequency shortcuts affect generalization to OOD datasets?
We expect that the frequency shortcuts specifically learned for CIFAR-10 would not generalize to OOD tests on ImageNet10, thus impacting negatively the classification accuracy.
We test on ImageNet-10 the models that we have trained on CIFAR-10, in order to evaluate OOD generalization and its relation with frequency shortcuts.
We carry out tests using the original ImageNet-10 images, and two filtered versions of them using the corresponding class-wise DFMs of the models trained on CIFAR-10.
In the first filtered version, we only keep the contributing frequencies of each class (referred to as ‘w/ df’), while the other version only includes the complementary remaining frequencies (referred to as ‘w/o df’) to test the case when shortcuts are explicitly removed.
In Table 1, we report numerical results regarding the percentage of contributing frequencies from the overall Fourier spectrum according to Algorithm 1, the corresponding degradation ∆ of performance measure as accuracy drop achieved when using only frequency from the DFMs to classify images of the different classes and the accuracy of OOD tests.
Classes with a low number of dominant frequencies, relatively small degradation and many false positive predictions are considered using frequency shortcuts.
We observed a considerable drop in performance, especially on the class ‘ox’, which corresponds to class ‘deer’ (for which we identified as shortcut) according to [15].
For images of the classes ‘ox’ and ‘tailed frog’ of the ImageNet-10 dataset, corresponding to ‘deer’ and ‘frog’ of CIFAR-10, the use of
[Table]
the dominant frequency only to perform classification results in a considerable drop of performance (for ResNet18 and ResNet50 specifically), worse than random, so generalizing poorly.
Interestingly, when forcing the classifier to ignore the shortcut learned on the CIFAR-10 dataset, namely filtering out the frequency contained in the DFMs of the classes with identified shortcuts, the results on the ‘ox’ and ‘tailed frog’ classes sharply increase.
This indicates that the frequency shortcuts learned on the CIFAR-10 dataset no longer existing in the OOD dataset affect the extraction of semantic and task-related cues and have a negative impact on generalization.
Does higher model capacity mitigate frequency shortcut learning?
In Fig.
1a, we observe that different models have similar frequency biases for classes ‘deer’, ‘frog’ and ‘ship’.
However, the values of ∆ in Table 1 indicate that the models learn slightly different frequency shortcuts.
ResNet uses more frequencies for classes ‘deer’ and ‘frog’ than ResNet18, showing a slight mitigation of learned frequency shortcuts as the capacity of the model increases.
However, ResNet50 uses fewer frequencies to perform classification for class ‘ship’ with small performance degradation, intensifying the learning of a different frequency shortcut.
On the contrary, ResNet9 learns to use a similar amount of frequencies to ResNet50 for the class ‘ship’ but with larger degradation of performance, indicating a less strong learned shortcut.
It is worth noting that the number of false positive predictions of classes with frequency shortcuts decreases (see Fig.
A.2 in Appendix A).
We think that this is determined by the classification model paying attention to a larger set of frequencies to perform the classification for all classes.
Although the experiments indicate a tendency of models with higher capacity to mitigate shortcut learning, we foresee the need for further investigation to better understand their relation.
This would help to design specific procedures that increase generalization.
Conclusions
We empirically investigated frequency shortcut learning in deep neural networks and designed a method to identify shortcuts in the Fourier domain.
We found that frequency shortcuts usually relate to textures consisting of a small set of frequencies that lead to biased predictions on certain classes.
We show that frequency shortcut learning is common across different architectures, and investigate its relation with model capacity.
Our preliminary results on CIFAR-10 and ImageNet-10 indicate that higher model capacity may contribute to mitigating the learning of frequency shortcuts, although deeper investigations are needed.
Acknowledgement This work was supported by the SEARCH project, UT Theme Call 2020,
Faculty of Electrical Engineering, Mathematics and Computer Science, University of Twente.
Appendix
[Figure] [Figure]