Learning explanations that are hard to vary
Authors: Giambattista Parascandolo
Alexander Neitz
Antonio Orvieto
Luigi Gresele
Bernhard Schölkopf
Venue: ICLR 2021 Poster (2021)
Keywords: invariances
consistency
gradient alignment

Abstract: In this paper, we investigate the principle that good explanations are hard to vary in the context of deep learning.
We show that averaging gradients across examples -- akin to a logical OR of patterns -- can favor memorization and `patchwork' solutions that sew together different strategies, instead of identifying invariances.
To inspect this, we first formalize a notion of consistency for minima of the loss surface, which measures to what extent a minimum appears only when examples are pooled.
We then propose and experimentally validate a simple alternative algorithm based on a logical AND, that focuses on invariances and prevents memorization in a set of real-world tasks. 
Finally, using a synthetic dataset with a clear distinction between invariant and spurious mechanisms, we dissect learning signals and compare this approach to well-established regularizers.

Published as a conference paper at ICLR 2021
LEARNING EXPLANATIONS THAT ARE HARD TO VARY
Giambattista Parascandolo Alexander Neitz'.
Antonio Orvieto Luigi Gresele Bernhard Schölkopf'.
'MPI for Intelligent Systems, Tübingen, 2ETH. Zürich. 2MPI for Biological Cyberneties, Tübingen
"qqul contribution
ABSTRACT
In this paper, we investigate the principle that good explanations are hard to vary in the context of deep learning. We show that averaging gradients across examples aakin to logical OR (v) of patterns can favor memorization and 'patchwork' solutions that sew together different strategies, instead of identifying invariances. To inspect this, we first formalize notion of consistency for minima of the loss surface, which measures to what extent minimum appears only when examples are pooled. We then propose and experimentally validate simple alternative algorithm based on logical AND (^), that focuses on invariances and prevents memorization in set of real-world tasks. Finally, using a synthetic dataset with a clear distinction between invariant and spurious mechanisms, we dissect learning signals and compare this approach to well-established regularizers.
INTRODUCTION
Average loss surface
Consider the top of Figure I which shows view from above of the loss surface obtained as we vary a two di- mensional parameter vector 0 (01. 02), for fictional dataset containing two observations AA and x Note the two global minima on the top-right and bottom-left. Depending on the initial values of 0 - marked as white circles gradient descent converges to one of the two minima. Judging solely by the value of the loss function, which is zero in both cases, the two minima look equally good.
8g
However, looking at the loss surfaces for FA and æB separately, as shown below, crucial difference between those two minima appears: Starting from the same ini- tial parameter configurations and following the gradient of the loss, (oL(0, æz), the probability of finding the same minimum the top-right either case is zero. In contrast, the minimum in the lower-left corner has a sig- nificant overlap across the two loss surfaces, so gradient descent can converge to it even if training on & (or B)) only. Note that after averaging there is no way to tell what the two loss surfaces looked like: Are we destroying information that is potentially important?
Loss surface for data
Loes surface for data B
Figure I: Loss landscapes of a aoopparmeeter model. Averaging gradients forgoes informa- tion that can identify patterns shared across dif- ferent environments.
In this paper, we argue that the answer is yes. In particular, we hypothesize that if the goal is to find invariant mechanisms in the data, these can be identified by finding explanations (e.g. model parameters) that are hard vary across examples. A notion of invariance implies something that stays the same, as something else changes. We assume that data comes from different environments: An invariant mechanism is shared across all, generalizes out of distribution (o.o.d.), but might hard to model; each environment also has spurious explanations that are easy to spot ("shortcuts') ). but do not generalize o.o.d. From the point of view of causal modeling, such invariant mechanisms can be interpreted as conditional distributions of the targets given causal features of the inputs; invariance of such conditionals is expected if they represent causal mechanisms, that is - stable properties of the physical world (see e.g. Hoover (1990)). Generalizing o.o.d. means therefore that the predictor should perform equally well on data coming from different settings, as long as they share the causal mechanisms.

---

Published as a conference paper at ICLR 2021
We formalize notion of consistency, which characterizes to what extent minimum of the loss surface appears only when data from different environments are pooled. Minima with low consistency 'patchwork' solutions, which (we hypothesize) expected to generalize to new environments. An intuitive description of this principle was proposed by physicist David Deutsch: "good explanations are hard to vary" (Deutsch) 201T).
together different strategies and should not be
Using the notion of consistency, we define Invariant Learning Consistency (ILC), a measure of the expected consistency of the solution found by learning algorithm on given hypothesis class. The ILC can be improved by changing the hypothesis class or the learning algorithm, and in the last part of the paper we focus on the latter. We then analyse why current practices in deep learning provide little incentive for networks to learn invariances, and show that standard training is instead set up with the explicit objective of greedily maximizing speed of learning, i.e., progress on the training loss. When learning "as fast as possible" is not the main objective, we show we can trade-off some "learning speed" for prioritizing learning the invariances. practical instantiation of IL.C leads to o.o.d. generalization to generalize; moreover, following the memorization task from Zhang et al. (2017), ILC prevents convergence CIFAR-10 10 with random labels, as no shared mechanism is present, and similarly when a portion of training labels is incorrect. Lastly, we set up a behavioural cloning task based on the game CoinRun (Cobbe et al. 2019b), and observe better generalization on new unseen levels.
challenging synthetic task where several established regularizers fail
An example. Take these two second-hand books of chess puzzles. We can learn the two independent shortcuts (blue arrows for the left book OR hand- written solutions on the right), or actually learn play chess (the invariant mechanism). While both strategies solve other problems from the same books (i.i.d.,, only the latter generalises new chess puzzle books (o.o.d.). How to distinguish the two? We would not have learned about the red
KoP
Rc5
arrows had we trained on the book on the right, and vice versa with the Hand-written notes.
EXPLANATIONS THAT ARE HARD TO VARY
We consider datasets (D* with | d, and D = (xf ; vf). i = 1,...,, n". Here xf E X S R the vector containing the observed inputs, and yf e = IRP the targets. The superscript e indexes some aspect of the data collection process, and can be interpreted as an environment label. Our objective infer function f X - which we call mechanism - assigning a target yf, to each input uf; as explained in the introduction, we assume that such function is shared across all environments. For estimation purposes, may be parametrized by neural network with continuous activations; for weights 0 θ c R" we denote the neural network output at X' as fe(x).
Gradient- based optimization. To find appropriate model fe. standard optimizers rely on gradi- ents from a pooled loss function L RR" - R. This function measures the average performance of the neural network when predicting data labels, across all environments: L(0) = le Σees Le (8), with (0) == نe. Ele; of )ED= {(f(2;; 0), v{); where l : R2 x R [0, +00) is usually chosen to be the L2 loss or the cross cross-entropy loss. The parameter updates according to gradient descent (GD) 0% VLL(())) where 7 0 is the learning rate. Under some standard assumptions (Lee et al. 2016). (0% converges to local minimizer of L, with probability one.
given by g
When do we not learn invariances? We start by describing what might prevent learning invari- ances in standard gradient-basee optimization.
(i) Training stops once the loss is low enough. If optimization learned spurious patterns by the time it converged, invariances will not be learned anymore. This depends on the rate at which different patterns are learned. The rates at which invariant patterns emerge (and vice-versa, the spurious patterns do not) can be improved by e.g.: (a) careful architecture design, e.g. done by hardcoding spatial equivariance in convolutional networks; (b) fine-tuning models pre-trained on large amounts of data, where strong features already emerged and can be readily selected.
2

---

Published as a conference paper at ICLR 2021
(ii) Learning signals: everything looks relevant for dataset of size 1. Due to the summation in the definition of the pooled loss L, gradients for each example are computed independently. Informally, each signal is identical to the one for equivalent dataset of size 1, where every pattern appears relevant to the task. To find invariant patterns across examples, if we compute our training signals on each of them independently, we have to rely the way these are aggregated
(iii) Aggregating gradients: averaging maximizes learning speed. The default method to pool gradi- ents the arithmetic mean. GD applied L is designed to minimize the pooled loss by prioritizing descent speed Indeed, step of GD is equivalent to finding a tight |qadratic upper bound & to C. and then jumping to the minimizer of this approximation (Nocedal and Wright 2006). While speed is often desirable, by construction GD ignores one potentially crucial piece of information: The gradient V is the result of averaging signals VLe, which correspond to the patterns visible from each environ- ment at this stage of optimization. In other words, GD with average gradients greedily maximizes for learning speed, but in some situations we would like to trade some convergence speed for invariance. For instance, instead of performing an arithmetic mean between gradi- ents (logical OR), might want to look towards logical AND, which can be characterized as a geometric mean. Fig. [ shows how a sum can be seen as a logical OR: the orthogonal gradients from data A and data B at (0.5,0.5) point to different directions, yet both are kept in the combined gradient In Sec. Sc3. we elaborate on this idea and on implementing a logical AND between gradients. Before presenting this discussion, we take some time to better motivate the need for invariant learning consistency and to construct precise mathematical definition of consistency.
(())
Figure 2: Inconsistency in gradient directions.
2.1 FORMAL DEFINITION OF ILC
Let 4% be the set of convergence points of algorithm A when trained using all environments (pooled data): that is, O = 10* E descent, the result of Lee et al. 2016) implies that 6* is the set of local minimizers of the pooled loss L. To each 8* E A we want to associate a consistency score, quantifying the concept "good I+h are hard to vary". In other words, we would like the score to capture the consistency of the loss landscape around 8* across the different environments. For example, in Fig. the loss landscape near the bottom-left minimizer consistent across environments, while the top-right minimizer is not. Let us characterize the landscape around 0* from the per- spective of fixed environment E E. We define the set No to be the largest path- nath-connected region of space con- taining both 0* and the set (0 θ s.t. C. (f) L. (0*) & e J. with e > O. In other words, if E N e. then there exist a path-connected region in parameter space including 8* and where each parameter also is in N _0 and its loss on environment is comparable. From the perspective of environment e, all these points are equivalent to 8*, We would like to evaluate the elements of this set with respect to a different environment e' e. We will say that e' is consistent with in O* if
00 E R" s.t. (z (09,00 E) = 0*). For instance, if A is gradient
Ni.
Loess curfice for data. A
Losss surface for data B
maX ** (0) - L. is small. Repeating this reasoning for all environment pairs, we arrive
at the following inconsistency score:
IT(#*) == max max (e,e")ega NEN:
(B*)
'ffter computing the gradients for dataset of n examples, if 1i-th example appeared, would just compute one more vector gradients and add it to the sum. Gaussian Process (Rasmussen) (0033 for
example would require recomputing the entire solution from scratch, as all interactions are considered.
'The same reasoning holds for SGD in the finite-sum optimization case L 5m Li. where gradients from mini-batch are seen as unbiased estimators of gradients from the pooled loss. (Bottou et al. (2018).
Assume that L has L-Lipschitz gradients (i.c. curvature bounded from above by L). Then, at any point 0,
we can construct the upper bound (g(0) L(0) + VC(0) T (0 8) + I.le - 012 //.
*I "oosely speaking, a sum is large if any of the summands is large, product large if all factors are large.
3

---

Published as a conference paper at ICLR 2021
This consistency is our formalization of the principle "good explanations are hard to vary". Finally, we can write down an invariant learning consistency score for AA:
ILC(A, poo) == - p0n [ (0x ,)]
(2)
That is, the learning consistency of an algorithm measures the expected consistency across environ- ments of the minimizer it converges to on the pooled data.
Example: low consistency of classic patchwork solution. One-hidden-layer networks with sigmoid activations and enough neurons can approximate any function f [0. 1] R (Cybenko 1989). In appendix A.I we show how the construction used to obtain the weights leads to maximally inconsistent solution according to Ie (0*), which would not be expected to generalize o.o.d.
2.2 ILC AS A LOGICAL AND BETWEEN LANDSCAPES
H Mg
H4i8
Here we draw a connection between our definition of inconsistency and the local geometric properties of the loss landscapes. For the sake of clarity, we consider two environments (A and B) and assume 8* be a local minimizer (with zero loss) for both environments. Using a Taylor approximation we get C(0) ~ (0 ) n 0*) for
Hana
||0 0*| R 0, where HA+B- -HA HB) 2 is the arithmetic mean of the Hessians НA == (0*) and HB == (6*) HA+B
Figure 3: Plotted are con- tour lines 8 H 0 I for HA = diag(0.05, 1) and HB = diag(1, 0.05). H HABB retains the original volumes, while for HA+B B it is 5x big- ger. This magnification shows incousistency
does not capture the possibly conflicting geometries of landscape A or B: It performs a "logical OR" on the dominant eigendirections. In contrast, the geometric mean, or Karcher mean, AA B (Ando et al. 2004) is affected by the inconsistencies between landscapes: It performs "logical AND". In appendix A.2, we give a formal definition of HA B
(et(HH++)))) As and show that for diagonal Hessians, (8*)) & 2c deti (et(H)))))
and B.
for the geometric mean of positive numbers, 0 a det [ A < det(HA+B) B); thus, inconsistency is lowest when shapes of A and are similar - exactly as in the bottom-left minimizer of Fig.
From Hessians to gradients. We just saw that the consistency of 0* is linked to the geometric mean of the Hessians ( (8")) Fee.. Under the simplifying assumption that each He is diagona @ and all cigenvalues X are positive, their geometric mean is H := The curvature of the corresponding loss in the i-th eigendirection depends on how consistent the cur-
Xς) \
( X;) (ee).
vatures of each environment are in that direction. Consider now optimizing from point 0h; gradient descent reads gk+1 0² -7!11* (0
where H1 = diag( [2T >iEEE Xi. TeT >'ne A For small enough we have | + 0 (1 7) T EeEE 00 0+1. As noted, this choice maximises the speed of convergence to 0² but does not take into account whether this minimizer is consistent. We can reduce the speed of convergence on directions where landscapes have different curvatures which would lead to a high inconsistency - by following the gradients from the geometric mean of the land- scapes, as opposed to the arithmetic mean. L.e, we substitute the full gradient V VL(0) H*( -*) with (0) = H - -0). Also, we have that
VL (0) (e V.. Meel to reduce the speed of convergence directions with inconsistency, we can take the element- wise geometric mean of gradients from different environments (see also Fig. 11 in the appendix).
2.3 MASKING GRADIENTS WITH LOGICAL AND
The element-wise geometric mean of gradients, instead of the arithmetic mean, increases consistency in the convex quadratic case. However, there are a few practical limitations:
(i) The geometric mean is only defined when all the signs are consistent. It still to be defined how sign inconsistencies, which can occur in non-convex settings, should be dealt with.
It provides little fiexibility for 'partial' agreement: Even single zero gradient component in one environment stops optimization in that direction.
'This provides a useful simplified perspective. Indeed, this quadratic model is heavily used in the optimization community (see e.g. Jastrzebski et al. (2017) :Zang et al. 20)9 Mandt et al. (2017).)
'It was shown in (Becker et al. 1988) and recently in (Adolphs et al. 2019 Singh and Alistarh 2020 that neural networks have strong diagonal dominance of the Hessian matrix at the end of training.
Smaller than 1 1/Amx. Amm is the maximum eigenvalue of Hessians from different environments,
"This holds if 0 8* is positive, otherwise we have VL (0) (eese (0)) ME
4

---

Published as a conference paper at ICLR 2021
(iii) For numerical stability, it needs to be computed in log domain (more computationally expensive).
(iv) Adaptive step-size schemes (e.g. Adam (Kingma and Ba 2015)) rescale the signal component- wise for local curvature adaptation. The exact magnitude of the geometric mean would be ignored and most of the difference from arithmetic averaging will come from the zero-ed components.
(i) can be overcome by treating different signs as zeros, resulting in a geometric mean of if there any sign disagreement across environments for gradient component. For (ii) can allow for some disagreement (with a hyperparameter), by not masking out if there is a large percentage of environments with gradients in that direction. (iii) and (iv) can be addressed together: Since the final magnitude will be rescaled except for masked components, i.e. where the geometric mean is O, we can use the average gradients (fast to compute) and mask out the components based on the sign agreement (computable avoiding the log domain).
The AND-mask. We translate the reasoning we just presented a practical algorithm that will refer to as the AND-mask. In its most simple implementation, we zero out those gradient components with respect to weights that have inconsistent signs across environments. Formally, the masked gradients at iteration l are m²(#") " VL(("). where m,(0") vanishes for any component where there are less than E {d/2, d/2 + I, ....., of environments in the batch), and is equal to one otherwise. For convenience, our implementation of the AND-mask uses a threshold r [0. 1] as hyper- payper-paramete instead of t, such that ((T + 1). Mathematically, for every component [m-lj of m., [m= = = [[rd & >> vign((VLe)))]]
...,,, d} agreeing gradient signs across environments (d is the number
Computing the AND-mask has the same time and space complexity of standard gradient descent, i.e., linear in the number of examples that we average. Due to its simplicity and computational efficiency, this is the algorithm that we will use in the experiment section. As a first result, we show that following the AND-masked gradient leads to convergence in the directions made visible by the AND-mask. The proof is presented in appendix [A.3]
Proposition 1. Let L have L-Lipschitz gradients and consider a learning rate 7 1/L. After k iterations, AND-masked GD visits at least once a point 0 where ([m,(0) O VC(O)) & O(1/k).
Behaviour in the face of randomness. Here we put the AND mask through theoretical test: For gradients coming from different environments that are inconsistent (or even ran-
Nomn the avenge grodeens
10'
10/
dom), how fast does the AND mask reduce the magnitude of the step taken in parameter space, compared to standard GD? In case of inconsistency, the AND mask should quickly make the gradient steps more conservative.
20
avengee gradienis
10
masked (upper bound)
16
N Number of e'eemmppess
To assess this property. we consider fixed set of n parameters O and gradients V drawn independently from multivariate Gaussian with zero mean and unit covariance.
Figure 4: Magnitude of gradient (aver- age or masked) on random data (0)) 3000, 0.8d).
Proposition 2. Consider the setting we just outlined, with L - (1/d) Σd. L.. While C O(n/d), we have that Vt {d/2 1,..., d), 3c (1,2) such that E (f) O V2 & (l/ce).
The proof is presented in Appendix A.4 and an illustration with numerical verification in Fig. 4 (the magnitudes of masked gradients (+) for more than 100 examples were always zero in the numerical verification). Intuitively, in the presence of purely random patterns, the AND-mask has a desirable property: it decreases the strength of these signals exponentially fast, opposed to linearly.
3 EXPERIMENTS
Real-world datasets are generated by (causal) generative processes which share mechanisms (Pearl 2009). However, mechanisms and spurious signals often entangled, making it hard to assess what part of the learning signal is due to either. As the goal of this paper is to dissect these two components understand how they ultimately contribute the learning process, we create simple synthetic dataset that allows us to control the complexity, intensity, and number of shortcuts in the data. After that, we evaluate whether spurious signals can be detected even in high-dimensional networks and datasets by testing the AND-mask on memorization task similar to the one proposed in Zhang et al. (2017), and on a behavioral cloning task using the game CoinRun (Cobhe et al. 2019a).
5

---

Published as a conference paper at ICLR 2021
Environment A
Environment B
Pooled A &
Test o.o.d.
AM
Figure 5: A 4-dimensional instantiation of the synthetic memorization dataset for visualization. Every example a dot both circles, it can be classified by finding either the "oracle" decision boundarics shown.
3.1 THE SYNTHETIC MEMORIZATION DATASET
We introduce binary classification task. The input dimensionality is d= dM + ds. While p(y|aax the same across all environments (i.e. the mechanism), p(y]=dg Idg; e) is not the same across all environments (the shorlcuts). While the mechanism is shared, it needs a highly non-linear decision boundary classify the data. The shortcuts are not shared across environments, way to classify the data, even when pooling all the environments together. See Figure for concrete example with d and dy equal 2, and two environments (A and B). The spirals (on d are invariant but hard to model. The shortcuts (on ds) are simple blobs but different in every environment: in A, linearly separable through a vertical decision boundary, in B with a horizontal one. If the two environments pooled, new diagonal decision boundary emerges the most 'natural' one. While this perfectly classifies data in both environments and B, critically it would have not been found by training (o.o.d.) test data has the same mechanism but random shortcuts. Therefore, any method relying exclusively the shorteuts will have chance-level o.o.d. performance. Details about the dataset, baselines, and training curves are reported in appendix
provide simple
the shortcut dimensions as
either partition A or B alone. The out-of-distrre of-distribution
Despite the apparent simplicity of this dataset, note that it is challenging find the invariant mechanism. In high dimensions, even with tens of pooled environments, the shortcuts allow for simple classification rule under almost every classical definition of "simple': the boundary is linear, has large margin, it can be expressed with small weights, it is fast to learn, robust to input noise, and has perfect accuracy and no i.i.d. generalization gap. Finding the complex decision boundary of the spirals, instead, is fiddly process and arguably a much slower path towards small loss.
Baselines. We evaluate several dogain-agnostic baselines (all multilayer perceptrons) with some of the most common regularizers used in deep learning Dropout, L1, L2, Batch normalization. We also consider methods that explicitly make use of the environment labels, namely: (i) Domain Adversarial Neural Networks (DANN) (Ganin al. 2016), a method specifically designed to address domain adaptation by obfuscating domain information with an adversarial classifier; (ii) Invariant Risk Minimization (IRM) (Arjovsky et al. ) discussed in detail in appendix is trained with the same configurations in Table
The AND-mask
Results. Fig. 6 shows training and test accuracy. DANN fails because it can align the representation- layer distributions from different environments using only shortcuts, such that they become indistinguishable to the was the only method to achieve perfect test accuracy, by fitting the spirals instead of the shortcuts. In par- ticular, the combination of the AND-mask with L.1 or L2 regularization gave the most robust results overall, as they help suppress neurons that at initialization are tuned towards the shortcuts.
1.0
0.9
classifier. The AND-mas
0.5
Test
0.4 Dropout, L2, L1
DANN
IRM
AND mask
(ouns)
Figure 6: Results on the synthetic dataset.
Correlations between average, memorization and generalization gradients. Due to the syn- thetic nature the dataset, we can intervene on its Lata-generating process order to examine the learning signals coming from the mechanisms and from the shortcuts. We isolate the two and measure their contribution to the average gradients, as we vary the agreement threshold of the mask. More precisely, we look at the gradients computed with respect to the weights of ran- domly initialized network for different sets of data: (i) The original data, with mechanisms and shorteuts. (ii) Randomly permuting the dataset "memorization" signal of the shortcuts. (iii) Randomly permuting over the shortcuts dimensions, isolating the "generalization" signal of the mechanisms alone. Figure 7 shows the correlation be-
the mechanisms dimensions, thus leaving the

---

Published as a conference paper at ICLR 2021
tween the components of the original average gradient (i) and the shorteut gradients (ii), dashed line), and between the original average gradients and the mechanism gradients ((ii), solid line).
While the signal from the mechanisms is present in the original average gradients (i.e. p & 0.4 for 7 = 0), its mag- nitude is smaller and it is 'drowned' by the memorization signal. Instead, increasing the threshold of the AND-mask (right side) suppresses memorization gradients due to the shortcuts, and for 2 most of the gradient components remaining contain signal from the mechanism. On the left side, we test the other side of our hypothesis: An XOR- mask zeroes out consistent gradients, preserves those with different signs, and results in sharper decrease of the correlation with the mechanism gradients.
Corvelation coofficieettt
1.00
0.75
my
0.25
YORommok
1.0
0.5
0.0
0.5
1.0
Agrecment threshold
Figure 7: Gradient correlations.
3.2 EXPERIMENTS ON CIFAR-10
Memorization in vision task. Zhang et al. (0117) showed that neural networks trained with standard regularizers - like L2 and Dropout can still memorize large training datasets with shuffled labels, i.e. reaching > 100% training accuracy. Their experiments raised significant questions about the generalization properties of neural networks and the role of regularizers in constraining the hypothesis class. Our hypothesis is that ILC - for example implemented as the AND-mac should prevent memorization on a similar task with the shuffled labels, as gradients will tend to largely 'dssagree' in the absence of a shared mechanism. However, when the labels are not shuffled, ILC should have a much weaker effect, as real shared mechanisms are still present in the data.
To test our hypothesis, ran experiment that closely resembles the one in (Zhang al. 2017) on CIFAR-IO. We trained a ResNet on CIFAR- 10 with random labels, with and without the AND-mask. In all experiments we used batch size 80, and treated each example its own "environment". Recall that standard gradient averaging is equivalent to an AND- mask with threshold 0. As shown in Figure the ResNet with standard average gradients memorized the data, while slightly increasing the threshold for the AND-mask quickly prevented memorization (dark blue line). In contrast, training the same networks on the dataset with the original labels resulted in both of them converging and generalizing to the test set, confirming that the mask did not significantly affect the generalization error with a general underlying mechanism in the data.
Note that there is no standard notion of environments in CIFAR- 10. which why we treated every example as coming from its own environment. This assumption is not unreasonable, as every image in the dataset was literally collected in dif- ferent physical environment. If anything, it is the standard i..d. assumption that hides this variety behind a notion of a single distribution encompassing all environments. The results of this experiment further support this interpretation, and can serve evidence that in some cases to identify invariances even without an explicit partition into environments, as this can be already identified the level of individual examples.
Trainig Acourcy
1.00
Standard Labels
0.50
Random Labels
0.00
0.05
0.10
3.20
0.00
0.00
0,80
Agu ceneenttt threshold
might be able
Figure 8: As the AND-mask threshold increases, memorization on CIFAR-10 with random labels is quickly hindered.
Label noise. Following up on this experiment, we test how the AND-mask performs the presence of label noise, i.e. when a portion of the labels in the training set are randomly shuffled (25% here). According our hypothesis, gradients computed on examples with random labels should disagree and get masked out by the AND-mask, while signal from correctly labeled data should contribute to update the model. As shown in Figure 99] the performance on the incorrectly labeled portion of the dataset is well below chance for the AND-mask (as it predicts correctly despite the wrong labels), while the baseline again memorizes the incorrect labels. On the test set (with untouched labels), the baseline peaks early then decreases as the model overfits, while the AND-mask slowly but steadily improves.
on midittebeel pontom
1.00
Trii Triisacuurr accumiyy
0.75
Ades
AND coud
0.25
Randan
0,00
0
Epoch
30
kpoch
80
Figure 9: The AND-mask prevents overfitting to the incorrectly labeled portion of the training set (left) without hurting the test accuracy (right).
7

---

Published as a conference paper at ICLR 2021
3.3 BEHAVIORAL CLONING ON COINRUN
CoinRun (Cobbe et al. 2019b) is a game introduced to test how RL agents generalize to novel situations. The agent needs to collect coins, jumping on top of walls and boxes and avoiding enemies O background, and layout- but the physics and goals are invariant. [Cobbe et al. (2019b) showed that state-of-the-art RL. algorithms fail model these invariant mechanisms, performing poorly on new levels unless trained on thousands of them. To test our hypothesis, we set up a behavioral cloning strong policy Λ* using standard PPO (Schulman 2017) for 400M steps on the full distribution of levels. We then generate a dataset of pairs (s, π [a[s)) from the on-policy distribution. The training data consists of 1000 states from each of 64 levels, while test data comes from 2000 levels. A ResNet-18 18 ft. is then trained to minimize the loss (* on the training set. We compare the generalization performance of regular Adam to a version that uses the AND-mask, For each method we ran an automatic hyperparameter optimization study using Tree- sreestruut Parzen Estimation (Bergstra et al.] 2013) of 1024 trials. Despite the theoretical computational efficiency of computing the AND- mask as presented in Section 2.3 (i.e., linear time and memory in the size of the mini-batch, just like classic SGD), current deep learning frameworks like
Each level is procedurally generated - i.c. it has different combination of sprites,
task using CoinRun 10 We start by pre-training
et al.
Behavioral Cloning on CoinRun
PyTorch (Paszke et al. 2017) have optimized routines that sum gradients across examples in mini- batch before it is possible to efficiently compute the AND-mask. We therefore test the AND-mask in a slightly different way.
1,80
KL divergence on tost
In training, in each iteration we sample batch of data from a randomly chosen level out of the 64 available (and cycle through them all once per
1.75
epoch). We then apply the AND-mask 'temporally' only allowing gradients that are consistent across time (and therefore across levels). See Algorithm in appendix [B66] for a detailed description of this alternative formulation of the AND-mask The figure shows the minimum test loss for the 10 best runs, supporting the hypothesis that the AND-mask helps identify invariant mechanisms across different levels.
Adam
Adam
AND-mask
4 RELATED WORK
Generalization and covariate shift. The classic formulation of statistical learning theory (Vapnik) concerns learning from independent and identically distributed samples. The case where the distribu- tion of the covariates at test time differs from the one observed during training is termed covariate shift (Sugiyama et al. 2007 Quionero-Cant Candela et al.] 2009 Sugiyama and Kawanabe (2022) Stan- dard solutions involve re- weighting of the training examples, but require the additional assumption of overlapping supports for train and test distributions.
Causal models and invariances. As we mentioned the Introduction, causality provides a strong motivation for our work, based on the notion that statistical dependencies are epiphenomena of an underlying causal model (Pearl 2009; Peters et al.) (017). The causal description identifies stable elements e.g. physical mechanisms connecting causes and effects, which are expected remain invariant under interventions or changing external conditions (Haavelmo) 1943) SScölkkoff et al.) 2012)). This motivates our notion of invariant mechanisms, and inspired related notions which have
been proposed for robust regression (Rojas-Carulla et al. 20188 Heinze-Deml et al. 2018 Arjovsky
al. 2019 Hermann and Lampinen 2020 Ahuja et al. 2020 Krueger et al. 2020 We discuss this
in more detail in appendix C.I
Domain generalization. ILC can be used in a setting of domain generalization Muandet et al. 2013).
but it is not limited to it: as demonstrated in the experiments in Section 3.2 the AND-mask can be applied even if domain labels are not available. In contrast, by treating every example as a single domain, methods relying on domain classifiers (like DANN Ganin et al. (0166) or Balaji al. (2018) would require as many output units as there are training examples (i.e. 50'000 for CIFAR-10). Gradient agreement. Looking at gradient agreement to learn meaningful representations in neural networks has been explored in (Du et al. 2018 EEhratifar et al.) 2018 Fort et al.) 2019 Zhang et al. 2019b). These approaches mainly rely on a measure of cosine similarity between gradients, which
9See Figure 17 appendix B.6 visualization the game.
To obtain robust evaluation, we preferred to approach behavioral cloning instead of the full RL problem, as it is standard supervised learning task and has substantially fewer moving parts than most deep RI. algorithms.
8

---

Published as a conference paper at ICLR 2021
did not consider here for two main reasons: (i) It is "global' property of the gradients, and it would not allow us to extract precise information about different patterns in the network; (ii) is unclear how to extend it beyond pairs of vectors, and for pairwise interactions its computational cost scales quadratic in the number of examples used.
CONCLUSIONS
Generalizing out of distribution is one of the most significant open challenges in machine learning, and relying invariances across environments examples may be key in certain contexts. In this paper we analyzed how neural networks trained by averaging gradients across examples might converge to solutions that ignore the invariances, especially if these are harder to learn than spurious patterns. We argued that learning signals are collected on one example at the time as is the case for gradients, e-g., computed with backpropagation can play a significant role in the patterns that will ultimately be expressed: Averaging gradients in particular can be too permissive, acting as a logical OR of a collection of distinct patterns, and lead to a "patchwork' solution. We introduced and formalized the concept of Invariant Learning Consistency, and showed how to learn invariances even in the face of alternative explanations that although spurious fulfill most characteristics of good solution. The AND-mask is but one of multiple possible ways to improve consistency, and it is unlikely to be practical algorithm for all applications. However, we believe this should not distract from the general idea which we trying to put forward namely, that it is worthwhile to study learning explanations that are hard to vary, with the longer term goal of advancing our understanding of learning, memorization and generalization.
the way these signals are aggregated
ACKNOWLEDGMENTS
We wish to thank Sehastian Gomez, Luca Biggio, Julius von Kügelgen, Paolo Penna, Ioannis Anagno, Ricards Mareinkevies, Sidak Pal Singh, Damien Teney for feedback on the manuscript, and thank Nando de Freitas for fruitful discussions in the early stage of this project. We also thank the Max Planck ETH Center for Learning Systems for supporting Giambattista Parascandolo, and the International Max Planck Research School for Intelligent Systems for supporting Alexander Neitz.
REFERENCES
L. Adolphs, J. Kohler, and A. Lucchi. Ellipsoidal trust region methods and the marginal value of hessian information for neural network training. arXiv preprint arXiv:1905.0920 092001 (version 1), 2019.
K. Ahuja, Shanmugam, K. R. Varshney, and A. Dhurandhar. Invariant risk minimization games. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, volume 119 of Proceedings of Machine Learning Research, pages 145-155. PMLR, 2020.
mir. creessvvlse (01119/ahuiaa00 a220a 2tm.a.....lmmmm.mm.mmm.m..... html
T. Ando, C.-K. Li, and R. Mathias. Geometric means. Linear algebra and its applications, 385: 305-334, 2004.
M. Arjovsky, L. Bottou, I. Guirajani, and D. Lopez-Paz. Invariant risk minimization. arXiv preprint arXiv:190.002893, 2019.
Y. Balaji, S. Sankaranarayanan, and R. Chellappa. Metareg: Towards domain generalization using nett-regullaizztiion. In S. Bengio, H. M. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi and R. Garnett, editors, Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NewrIPS 2018, December 3-8, 2018, Montréal, Canada, pages 1006-1016, 2018. URL https: http::::/pppooceeeeeee neurips. cc /aper/ 2018/hash/
7c81 (w00000000220200 oa0.aaa4400...e11111000000000110 Abst htmm
S. Becker, Y. Le Cun, et al. Improving the convergence of back pook-propagation learning with second order methods. In Proceedings of the 1988 connectionist models summer school, pages 29-37, 1988.

---

Published as a conference paper at ICLR 2021
J. Bergstra, D. Yamins, and D. D. Cox. Making science of model search: Hyperparameter optimization in hundreds of dimensions for vision architectures. In Proceedings of the 30th International Conference Machine Learning. ICML 2013, Atlanta, GA, USA, 16-21 June 2013, volume 28 of JMLR Workshop and Conference Proceedings, pages 115-123. J.....o...org 2013. URL htt.::t/ppp..eeee
ngs .m wtt.m.....rrrs/e////errssaaaaaaa
html
Bottou, F. Curtis, and Nocedal. Optimization methods for large-scale machine learning. Siam Review, 60(2):223-311, 2018.
K. Cobbe, O. Klimov, C. Hesse, T. Kim, and J. Schulman. Quantifying generalization in reinforcement learning. In K. Chaudhuri and R. Salakhutdinov, editors, Proceedings of the 36th International Conference on Machine Learning, ICMI. 2019, 9-15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pages 1282-1289. PMLR, 2019a. URL mwr. wwwss/ wtt.://bbbee....
wttps/////eeobbbll......... html
K. Cobbe, O. Klimov, C. Hesse, T. Kim, and J. Schulman. Quantifying generalization in reinforcement learning. In K. Chaudhuri and R. Salakhutdinov, editors. Proceedings of the 36th International Conference on Machine Learning. ICML 2019, 9-15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pages 1282-1
122--128 289. PMLR, 2019b. URL ngs. mml...r....mmmmmm.....m.... press 997 cobbe 9a. html
K. Cobbe, C. Hesse, J. Hilton, and J. Schulman. Leveraging procedural generation to benchmark reinforcement learning. Proceedings of the 37th International Conference on Machine Learning. ICML 2020, 13-18 July 2020, Virtual Event, volume 119 of Proceedings of Machine Learning Re- search, pages 2048-2056, PMLR, 2020. URL httt:://proceeeeeeeeee cobbe20a html
wwaggssmm..... www.mml.ppp.. walr.press/vie
G. Cybenko. Approximation by superpositions of sigmoidal function. Mathematics of control, signals and systems, 2(4):303-314, 1989.
D. Deutsch. The beginning of infinity: Explanations that transform the world. Penguin UK, 2011.
Y. Du, W. M. Czarnecki, S. M. Jayakumar, R. Pascanu, and B. Lakshminarayaman. Adapting auxiliary losses using gradient similarity. arXiv preprint arXiv:1812.02224, 2018.
A. E. Eshratifar, D. Eigen, and M. Pedram. Gradient agreement as an optimization objective for meta-learning. arXiv preprint arXiv:1810.08/77, 2018.
S. Fort, P. K. Nowak, and S. Narayanan. Stiffness: A new perspective on generalization in neural networks. arXiv preprint arXiv: 190100999000 2019.
Y. Ganin, E. Ustinova, H. Ajakan, P. Germain, H. Larochelle, F. Laviolette, M. Marchand, and
V. Lempitsky. aevesriadversariill training of neural networks. The Journal of Machine Learning Research, 17(1):2096- 2030, 2016.
T. Haavelmo. The statistical implications of a system of simultancous equations. Econometrica, 11 (1), 1943.
C. Heinze-Demi Demb and N. Meinshausen. Conditional variance penalties and domain shift robustness. arXiv preprint arXiv: 1tt117700.11666 2017.
C. Heinze-Deml, J. Peters, and N. Meinshausen. Invariant causal prediction for nonlinear models. Journal of Causal Inference, 6(2), 2018.
K. L. Hermann and A. K. Lampinen. What shapes feature representations? exploring datasets, architectures, and training. In H. Larochelle, M. Ranzato, R. Hadsell, M. Bal- can, and H. Lin, editors, Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020. URL
F1e9c6620038 160103361161111100 0aA00006666699444440eeeee0 T1566555000055551066666444440000
.html
K. D. Hoover. The logic of causal inference: Econometrics and the conditional analysis of causation. Economics & Philosophy, 6(2):207-234, 1990.
10

---

Published as a conference paper at ICLR 2021
L. Hurwicz. On the structural form of interdependent systems, In E. Nagel, P. Suppes, and A. Tarski, editors, Logic, Methodology and Philosophy of Science, Proceedings of the 1960 International Congress, pages 232-239. Stanford University Press, Stanford, CA, 1962.
D. Janzing. Causal regularization. In H. M. Wallach, H. Larochelle, A. Beygelz- imer, F. d' d'Alché-Buc, E. B. Fox, and R. Gamett, editors, Advances in Neural Infor- mation Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurlPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 12683 12933, 2019. URL htttps::/proceeeeeie new.niiinnnnn...p..o..o.mm 2272220-930110777702223323333333
neurips wctpaper/200 9/ 9/hash/ Abstract html
S. Jastrzæbski, Z. Kenton, D. Arpit, N. Ballas, A. Fischer, Y. Bengio, and A. Storkey, Three factors influencing minima in sgd. arXiv preprini arXiv: 2017.
D. Kingma and J. Ba. Adam: A method for stochastic optimization. In Y. Bengio and Y. LeCun, editors, 3rd International Conference on Learming Representations, ICLR 2015, San Diego CA. USA, May 7-9, 2015, Conference Track Proceedings, 2015. URL 1412. 6980]
D. Krueger, E. Caballero, J.-H. Jacobsen, A. Zhang, J. Binas, R. L. Priol, and A. Courville. Out-of- distribution generalization via risk extrapolation (rex). arXiv preprint arXiv:2003. 00688. 2020.
J. D. Lee, M. Simchowitz, M. Jordan, and B. Recht. Gradient descent converges to minimizers. arXiv preprint arXiv:1602.04913 2016.
S. Mandt, M. D. Hoffman, and D. M. Blei. Stochastic gradient descent as approximate bayesian inference. The Journal of Machine Learning Research, (00))44433349007 2017.
J. M. Mooij, D. Janzing, J. Peters, and B. Schölkopf. Regression by dependence minimization and its application to causal inference in additive noise models. In A. P. Danyluk, L. Bottou, and M. L. Littman, editors, Proceedings of the 26th Annual International Conference on Machine Learning, ICML 2009, Montreal, Quebec, Canada, June 14-18, 2009, volume 382 of ACM International Conference Proceeding Series, pages 745-752, ACM, 2009, doi: 10. (0.1144//533374.16 1553477. URL
https: //doi. wrgg/o.................oo...o... 113.1111313333334433333133
K. Muandet, D. Balduzzi, and B. Schölkopf. Domain generalization via invariant feature repre- sentation. In Proceedings of the 30th International Conference on Machine Learning, ICML 2013, Atlanta, GA, USA, 16-21 June 2013, volume 28 of JMLR Workshop and Conference Pro- ceedings, pages 10-18. JMLR.org, 2013. URL http::ttppppppeeeaaeeaaaa muandet13: html
mlr. www.ppresssve.. /
J. Nocedal and S. Wright. Numerical optimization. Springer Science & Business Media, 2006.
G. Parascandolo, N. Kilbertus, M. Rojas-Carulla, and B. Schölkopf. Learning independent causal mechanisms. J. G. Dy and A. Krause, editors, Proceedings of the 35th International Conference Machine Learning, ICML 2018, Stockholmsmässsan, Stockholm, Sweden, July 10-15, 2018, volume 80 of Proceedings of Machine Learning Research, pages 4033 4041. PMLR, 2018. URL http:://procedding
mww. press wttps//v//paaaacaaa/..ee http://aaacaanooola..aaam. html
A. Paszke, S. Gross, S. Chintala, G. Chanan, E. Yang, Z. DeVito, Z. Lin, A. Desmaison, L.. Antiga, and A. Lerer. Automatic differentiation pytorch, 2017.
J. Pearl. Causality: Models, Reasoning, and Inference. Cambridge University Press, 2nd edition, 2009.
J. Peters, P. Bühlmann, and N. Meinshausen. Causal inference by using invariant prediction: iden- tification and confidence intervals. Journal of the Royal Statistical Society: Series (Statistical Methodology), -847 2016.
J. Peters, D. Janzing, and B. Schölkopf. Elements of Causal Inference Foundations and Learning Algorithms. MIT Press, Cambridge, MA, USA, 2017.
J. Quionero-Caame Candela, M. Sugiyama, A. Schwaighofer, and N. D. Lawrence, Dataset shift in machine learning. The MIT Press, 2009.
11

---

Published as a conference paper at ICLR 2021
C. E. Rasmussen. Gaussian processes in machine learning. In Summer School on Machine Learning. pages 63-71. Springer, 2003.
M. Mojas-Carulla, B. Schölkopf. R. Turner, and J. Peters. Invariant models for causal transfer learning. The Journal of Machine Learning Research, 19(1): (91)::309-1142, 2018.
B. Schölkopf. Causality for machine learning, 2019, arXiv:1911.10550
B. Schölkopf, D. Janzing, Peters, Sgouritsa, K. Zhang, and M. Mooij. On causal and anticausal learning. In Proceedings of the 29th International Conference Machine Learning, ICML 2012, Edinburgh, Scotland, UK, June 26 July 1, 2012. icml.c// Omnipress, 2012. URL 625.pd..........
http:// cmml..mmmm.....m.mmmmm...//..... wtt.emccc.ccceeeemmmmmmee/mm wtt.cc/////.capp.e
J. Schulman, F. Wolski, P. Dhariwal, A. Radford, and O. Klimov. Proximal policy optimization algorithms. arXiv preprint
2017.
H. A. Simon. Causal ordering and identifiability. In W. C. Hood and T. C. Koopmans, editors, Studies in Econometric Methods, pages 49-74. John Wiley Sons, New York, NY, 1953. Cowles Commission for Research in Economics, Monograph No. 14.
S. P. Singh and D. Alistarh. Woodfisher: Efficient second-order approximations for model compres- sion. arXiv preprint 1rXiv:2004.14340 2020.
A. Subbaswamy, P. Schulam, and S. Saria. Preventing failures due to dataset shift: Learning predictive models that transport. In K. Chaudhuri and M. Sugiyama, editors, The 22nd International Conference on Artificial Intelligence and Statistics, AISTATS 2019, 16-18 April 2019, Naha, Okinawa, Japan, volume 89 of Proceedings of Machine Learning Research, pages 3118-311 1-2777. PMLR, 2019. ARLhttp::/ pttppeeccceeeienneeoeeee mlr. press / vt9/ wt9////ba//a..e subbaswamyy 1 19a. html
M. Sugiyama and M. Kawanabe. Machine learning in non-stationary environments: Introduction to covariate shift adaptation. MIT press, 2012.
M. Sugiyama, M. Krauledat, and K.-R. Müller. Covariate shift adaptation by importance weighted cross validation. Journal of Machine Learning Research, ((May):985-100s. 2007.
V. N. Vapnik. The nature of statistical learning theory. Springer-Verte Verlag New York, Inc. ISBN 0-387-94559-8.
J. von Kügelgen, A. Mey, and M. Loog. Semi-generative modelling: Covariate-shiff adaptation with cause and effect features. In K. Chaudhuri and M. Sugiyama, editors, The 22nd International Conference Artificial Intelligence and Statistics, AISTATS 2019, 16-18 April 2019, Naha, Okinawa, Japan, volume 89 of Proceedings of Machine Learning Research, pages 1361-1369. PMLR, 2019. http:ttt::/prccceddnngee/ ml wtt.mm.p..eee///////e/e///
9a. html
C. Zhang, S. Bengio, M. Hardt, B. Recht, and O. Vinyals. Understanding deep learning requires rethinking generalization. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net, 2017. URL
net. htt///orumm/// SonammmdddSyyBB33333
G. Zhang. I.. Li, Z. Nado, J. Martens, S. Sachdeva, G. E. Dahl, C. J. Shallue, and R. B. Grosse. Which algorithmic choices matter at which batch sizes? insights from a noisy quadratic model. In H. M. Wallach, H. Larochelle, A. Beygelzimer, F. d' Alché-Buc Buc, E. B. Fox, and R. Gamett, editors, Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurlPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 8194 8205, 2019a. URL httppppppppppppppegeg......pe neurips. cctppspppppppppppcccccc 9/hash/ 0lacc
html
Y. Zhang, W. Yu, and G. Turk. Learning novel policies for tasks. In K. Chaudhuri and R. Salakhutdi- nov, editors. Proceedings of the 36th International Conference on Machine Learning. ICML 2019, 9-15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pages 7483-7492. PMLR, 2019b. URL http:: http://ooooeedng....o. mlr press/ 2007/hhagll 9tmllml
12

---

Published as a conference paper at ICLR 2021
A APPENDIX TO SECTION 2
A.1 A CLASSIC EXAMPLE OF A PATCHWORK SOLUTION
Consider a neural network with one hidden layer consisting of two neurons and sigmoidal activations:
fo(x) (0 82) + (,0 04), o(2) :
(3)
We want learn the continuous function f* [0 - [0, 2] defined
0
[0, 0.4);
10(x 0.4)
[0.4, 0.5);
(x)
æ E [0.5, 0.7);
10(x 0.7)
+
x E [0.7, 0.8);
2
[0.8, 1].
To perform this task, we have access (noiseless) data from two environments:
A: {z. f(=)) (0,0.5)), B {(x, (())) e [0.5, 17}.
There is simple constructive way, provided by the universal function approximation theorem Cy benko (189) to fit this function using fo up to arbitrarily small mean squared error C B 0*). Leaving out the details of such a construction (Cybenko) (1899) for details), the reader can check on the left panel of Figure I0 that 8* (100. 50, 100, -75, 1, provides good fit for both environments and B both LA and L LB(0* (0*) are small.
10
248
fe
f
[()
34
Environment
02
0 8+ (100, -40, 100,
-75, -,,,111 1)
0 0 (100, -5,, 100, -75, 1, -0.5)
Figure 10: Performance the neural network in Equation for two different parameters. Any reasonable modification on dg (say +1) leaves the performance on environment A unchanged, while the performance on environment B quickly degrades.
However, it is easy to realize that 0* - while being solution which can be returned by gradient descent using the pooled data A+B is not consistent (formal definition given in the main paper in Section 2). Indeed, it is possible to modify 0* such that the loss in environment remains almost unchanged, while the loss in enviromment B gets larger. In particular, on the right panel of Figure IO we show that 8* = (100, -50, 100, -75, 1, 0.5)) is such that ( < LA(#*) + (with very small) but (z((*) Lz((0)) According to our definition in Equation (see main paper), we have
I'(0") & [f*) LB((*)
that is a large number (low consistency).
Remark 1 (Connection out of distribution generalization). The main point of this analysis was to show an example of where our measure of consistency behaves according to expectations: A typical implementation of the universal approximation theorem which one would not expect to generalize out of distribution, due to its 'patchwork' behavior - leads indeed to very low consistency score.
For graphical description, the reader can check com/ chap4. h
13

---

Published as a conference paper at ICLR 2021
A.2 SECTION 2.2 CONSISTENCY AS ARITHMETIC/GEOMETIE MEAN OF LANDSCAPES
Geometric mean of matrices. Given an n-tuple of x d positive definite matrices geometric (Karcher) mean AAdd et al. 2004 is the unique positive definite solution X to the equation 2i=1 (A, x) = O, where log is the matrix logarithm. This matrix average has many desirable properties, which make relevant to signal processing and medical imaging. The Karcher mean 2m L d( (i, X) where d is the Riemannian distance in the manifold of SPD matrices S (d).
the
can also be written arg min Xes (d) f(X)
Loss env
Loss emy B
Arithmetic mean
Geametric mean
3.6
3.1
0
0-
2.6
0.5
0.0
3.1
2.6
-1
-1
0.5
0.0
3.1
2.6
0.5
1
0.0
4.6
4.1
1.1
2.5
2.0
1
While the arithmetic mcan of the two loss surfaces on the left identical in all three cases (third column), the geometric mean has weaker and weaker gradients (black arrow) the more inconsistent the two loss surfaces become.
Figure 11:
Link between consistency and geometric means. Here show how the consistency score introduced in Equation can be linked (in simplified setting) to a comparison between the arithmetic and geometric means of the Hessians approximating the landscapes of separate environments A and B.
At the local minimizer 0* 0, we assume that LA Lp 0 and consider the local quadratic approximations (0) = 100 A and LB( _f Hg0. Here, we make the additional simplifying assumption that HA and HB are diagonal (or, more broadly, co-diagonalizable): A."), with X > 0 and X," > 0 for all = 1,.... The arithmetic and geometric means (noted as M and H HAAD) n) of these matrices are defined in this simplified setting as follows:
HA diag( X x²), HB = diag(A
HA+ diag (1 A
1 -
+ AB)
HAAB diag (AMAP,.... ....... VAAA
As motivated in the main paper and in Figure 12 one can link the consistency of two landscapes to comparison between the geometric and arithmetic means of the corresponding Hessians.
Proposition 3. In the setting we just described, the consistency score in Equation can be estimated as follows:
det( det(H H
( & 2c
det( H HAAB)
14

---

Published as a conference paper at ICLR 2021
arithmetic (logical OR)
grometric (Iogiral AND)
A
AA
Hg
Hg
HALB
Figure 12: Plotted are contour lines 0 00 = for HA = diag(0.01,, 1) and HB = diag 0.01). It is convenient to provide this visualization because it linked the matrix determinant: Vol((0 '0' = 13) (I). The geometric average retains the volume of the original ellipses, while the volume of HA+B is times bigger. This magnification indicates that landscape is not consistent with landscape B.
Before showing the proof, note that the proposition gives a lower bound on the consistency. That is, it provides a pessimistic estimate. Yet, as we motivated, this estimate has a nice geometric interpretation. However, as outline in remark after the proof, this estimate is tight in two important limit cases.
Proof. In this setting, Equation I gives
max LB(0), max Ca(0)).
(**))) == max
(Ca())
La(l)
Recall that
1 0 HAO
1 1A..
(x
2
Hence, this is a simple quadratic program with quadratic constraints, and
max (
(n())= = max
Σ Aeo.
I, 188EE 2
Further, we can change variables and introduce 0, 0:v /2. The problem gets even simpler:
B 0² = max
A
max CB(0)= (0)
max 10
X
All in all, we get
X
A
I (8+)) max max
A
max
max max
2B
A/1
& C. max
+
1/
1/
(AP)) (AA)2
max
1 A
(AP + Ad)22
$ C- max
This means
XB + A max (A + 1x)/2 < 2c
IL + x/1/2 det HA+B) 2c
VI*(M* & cmax
V
Il. VA'x"
det(HA B)
where the first inequality comes from the monotonicity of the square root function, and the second inequality comes from the fact that (i) the geometric mean is always smaller or equal than the arithmetic mean and (ii) for any sequence of numbers a; 1, max; 0g & az
n
15

---

Published as a conference paper at ICLR 2021
Remark 2 (Sanity check). There are two important cases where test the bound above. First, if HA = H.. then (0*) 6, and the bound returns Z' (8*) & 2c, since the geometric and arithmetic mean are the same. Next, say X 0 but X 0; then, both the bound and the inconsistency score are oc (highest possible inconsistency).
A.3 PROOF OF PROPOSITION
In this appendix section we consider the AND-masked GD algorithm, introduced the end of Section 2 We recall that the masked gradients at iteration & are m0 O V VL(0"), where m, (0*) vanishes for any component where there are less than {d/2 + ......,d d} agrecing gradient signs across environments, and is equal to one otherwise. In full-batch setting, the algorithm is
gh+ 6³ 17 m. (0*) O VL((").
(AND-masked GD)
where 1j 0 is the learning rate. Proposition 1. Let L have L-Lipschitz gradients and consider learning rate 7 1/L. After k iterations, AND-masked GD visits at least once a point 0 where llm;(0)) O VL(O) & O(1kk)
Proof. Thanks to the component-wise L-smoothness and using Taylor expansion around Ø have
((8++1) < C(0*) VVVC(()) + VV((') Ln²
VC(0')
= -(0') (17 Li7² 2
|m, O V2 VV(6)))
If we seek 7) - Ln 2/2, then < 1 L. we assumed in the proposition statement. Therefore, L((i+1) & L(0') - (n/ (m) C 113 for all >> 0. Summing over i from 0 to desired
iteration k, we get
(n/2) ( o (m)2))m(())) C(09) -((t) < C(0)).
Therefore,
[mm(0') 12 Σ (m))) 2C(00) np
min i-....ck
Hence, there exist an iteration i* {O...... k} such that (m J VL <
A.4 PROOF OF PROPOSITION 2
Here we fix parameters 9 E IR" and assume gradients (ee( E R" coming from environments e are drawn independently from multivariate Gaussian with zero mean and o covariance. We want to show that, in this random setting, the AND-mask introduced in Section 2.3 decreases the magnitude of the gradient step.
Proposition 2. Consider the setting just outlined, with L = 1/dd)= Ce. While = O(n/d), we have that VI {d/2 1,..,, d), Jc E (1,2) such that E m0)))))))) o V2(0)] & O(nee).
Proof. Let us drop the argument 0 for ease of notation. First, let us consider V (no gradient AND-mask):
de E EV. 2= no²
E
VC.
where in the first equality we used the fact that the VL,, are uncorrelated and in the second the fact that Le; []]] is the trace of the covariance of V Le.-
16

---

Published as a conference paper at ICLR 2021
Next, assume we apply the element wise AND-mast my to the gradients, which puts zero the components (dimensions) where there are less than t E (d/2...., d] equal signs. Since Gaussians are symmetric around zero, the probability of having exactly u positive j-th gradient component among
environments is Pr(p, = u) = (2)* (.) Hence, the probability to keep the j-th gradient direction (considering also negative consistency)
d-t Σ 1-
Pr[[me] 1]
Σ n-
Pr(py u)
Pr(p, u)
1
d
+
2
k)
k=t
k=
d
d K3
2
(4)
We would now like to compute E m4 O (+ VL.a)) 1 The difficulty lies in the fact that the event my = makes gradients conditionally dependent. Indeed, conditioning on both m, = 1 and [e 0 changes the distribution of [e this gradient entry is going to be more likely to be positive or negative, depending on the value of [V Lel; and on the details of the gradient mask. To solve the issue, we our strategy is reduce the discussion (without loss in generality and with no additional assumption) to the case where gradient entries have all the same sign and hence conditional independence is restored.
We consider the following writing for the quantity we are interested in:
d
2
d
2
E m.
O
V
Les
=
E
[mlss
à
d
1 [
Σ
[me]i
à
PJ = D1j
Pr[p; 10}
B9
E
à
1
ΣΣ
[Vcccll )
d
2
ps= Doj
Pr(p, = 2yJ
1
d
|03 |ps-
1
d
2
E
)
2
3= -
where we used the definition of 2-norm, the law of total expectation, and the symmetry of the problem with respect positive and negative numbers. Finally, since the gradient components within the same environment are conditionally independent, for any j E .I.....n} we can write
d
2
d
1
1
d (VC..)) ) 'pp-
-Bs Bs ]
1
E m,
O
VL.
= 2n
E
2
Finally, we note that the following bound holds:
E I EIVE..)) ) |p=
(
( d ppp- d
)
2 Pj
Ps
P3 & d
Indeed, if all environments lead to positive (or, symmetrically, negative) and non-interacting gradients in the j-th direction, the average will be the biggest in norm. Moreover crucially conditioned on the event p, = d, gradients coming from different environments are distributed as a positive half-normal distributions. Moreover, they are conditionally independent; this because, since they
17

---

Published as a conference paper at ICLR 2021
all positive, the value of gradient in one environment cannot influence the value of the gradient in another one. We remark that conditional independence on the right-hand side is therefore not an assumption, but is intrinsic to the upper bound.
Putting all together, we have
E my
O
VLe
2
$
2n
Σ
d
EF
1 d
Σ
V
( )
2 p2.
1p0
(-]
d
d
d
2
P/-t
d
d d
Σ o²
& 2n
2
53)
$ o nd 1) (
1
d-1
2
where in the second line we bounded the squared average of a sum of half normal distributions: let (X:) be family of uncorrelated positive half-normal distributions derived from Gaussians with
mean zero and variance o², we have that E [[ / π and E[X?] o². Also, E[X;X,]
E[X, [xx] E o². Therefore,
2
d Σ B[X,X,] [xx,
E
X
1,==1
Finally, if we set r = t/d E (0.5, 1]. we have
1 d ( r'11 (7-))--))-)
as d + co (discarding all polynomial terms). Hence (9) is of the form d², with 1 < q <x3 2. So, the quantity o²n(d- - f) ( (t) will be exponentially decreasing at rate On/((2 g) Notably, if t = d/2, then we lose the exponential rate and get back to On//d).
phhttss://et wik http://wwwwiiiiiia..oo hirt:///aaalatoommmmaaaaaarrrrrr atriiibuuttrtrttooooo
Theorem in Burié, Tomislav, and Neven Elezović. "Asymptotic expansions of the binomial coefficients."
Journal of applied mathematies and computing 46. 1-2 2014): 135-145.
18

---

Published as a conference paper at ICLR 2021
B APPENDIX TO SECTION
We used Pytorch Paszke et al. 2017) to implement all experiments in this pa- https://github.. com/
per. Our codebase is publicly available at
learning see-exxlaane explanations hard to vary
B.1 SECTION 3.
Table 1: Hyperparameter ranges for synthetic data experiments. The regularizers LI and L.2 are never combined; instead, weight regularization type of L1, L2 and none selected and sample from the respective range afterwards.
Hyperparameter
Ranges
No. hidden units
{256, 512)
No. hidden layers
{3. 5
Batch-size Optimizer
{64, 128, 256
(Adama, -0..0,000. SGD + momentumo
Learning rate natch-normalization
{1e-3, le-2, le-1
Yes,, No
Dropout
{0.0, 0.5
1.2 regularization
(le-5, le-4, 1e-3)
regularization
[le-6, le-5, le4)
B.2 DATASET
Here report more technical details about the synthetic dataset described in Each example is constructed as follows: we first choose the label randomly be either +1 11, with equal probability. The example is vector with ds + dı entries, consisting of the shortcut and the mechanism. In experiments, d and dg 32.
Section 3
The Gaussian shortcuts are obtained by first sampling one random vector X, Iede per environment. Its components Fs.i sampled independently from a Normal distribution: Fe,i ~ (0, 0.1). We use x, for class and -x, for class -1. In the test set, all shortcut components are sampled i.i.d. from the same Normal distribution. Effectively, each example of the test set belongs to different domain. The mechanism is implemented as the two interconnected spirals shown in Figure 13 by sampling the radius ~ Unif 1.0) and then computing the angle as a = 2wrrr where n is the number of revolutions the spiral. We add uniform noise in the range (-002, 0.02] to the radii afterwards.
Figure 13: The spirals used as the mechanism in the synthetic memo- rization dataset.
The training dataset consists of 1280 examples per environment and we use D 32 environments unless otherwise mentioned. The training datasets consists of 2000 examples.
B.3 EXPERIMENT
We train all networks for |000 D] epochs, dropping the learning rate by a factor 10 halfway through, and again three-quarters of training. For computational reason, stop each trial before completion the training accuracy exceeds 97% and the test accuracy is below 60%. All networks are ML.s with LeakyReLU activation functions and cross-entropy loss on the output. We run hyperparameter search over the ranges shown in Table [ For IRM and the AND-mask, we select the best-performing run and re-run it 50 times with different random seeds. For DANN and the standard baselines nothing produced results significantly better than chance.
B.3.1 STANDARD REGULARIZERS AND AND-MASK
The networks with the LI, L2, Dropout and noraalizoomiiiiionnnn regularizers, have hyperparameters that were randomly selected from Table 1
For the AND-mask used the very same ranges. The
19

---

Published as a conference paper at ICLR 2021
regularizers L1 and L2 are never combined; instead, one weight regularization type out of L1, L2 and none is selected and we sample from the respective range afterwards. The parameters found to work best from the grid search were: agreement threshold of 1, 256 hidden units, hidden layers, batch size 128, Adam with learning rate le-2, no batch norm, no dropout, 1.2-regularization with a coefficient of le-4, -e--euularization. In practice, often found it helpful to rescale the gradients after masking to compensate for the decreasing overall magnitude. We add the option for gradient rescaling as an additional hyperparameter, as found it to help in several experiments. rescales gradient components layer-wise after masking, by multiplying the remaining gradient components by c, where e is the ratio of the number of components that layer over the number of non-masked components in that layer (i.e. the sum of the binary elements in the mask) 14 very large layers, a less extreme normalization scheme or the additional use of gradient clipping might be appropriate.
We speculate that for
B.3.2 DOMAIN ADVERSARIAL NEURAL NETWORKS
The experiments using DANN follow similar pattern. The model consists of embedding network. a classification network, and a "domain discrimination" network. All three modules are two-layer multi-layer perceptrons (MLP). The number of hidden units of all MLPs sampled from the range specified in Table I and we trained 100 models. Both label classifier and domain discriminator applied to the output of the embedding network. The label classifier is trained to minimize the cross-entropy-loss between the predicted and the true label. Similarly, the domain discriminator is trained minimize the loss between predicted and true domain-label. The embedding network is trained to minimize the regular task classification loss and at the same time to maximize the the domain-loss achieved by the domain discriminator.
B.3.3 INVARIANT RISK MINIMIZATION
For the experiments using IRM we used the authors' PyTorch implementation from https 7/gi thub. wwcpo//aacbooooooo rewearceeeereeee Invariarn ant akMi nimi zatior) We perform
random hyperparameter search over with the ranges shown in Table 2
Table 2: Hyperparameter ranges for IRM.
Hyperparameter
Ranges
No. hidden units
{256, 512]
No. hidden layers
(3, 5)
Batch-size
{64, 128, 256 a...aaa-....,....... SGD momentumo {Yes, No {10.0, 10000.
Optimizer
Batch-normalization
Penalty weight
Number of annealing iterations
{0.1, 2, 4, 8) {1e-3, 1e-2. le-1, 1)
Learning rate
B.3.4 CURVES FOR ALL EXPERIMENTS
In Figure 14 we show the learning curves of training and test accuracy for the different methods.
B.3.5 CORRELATION PLOTS
For the correlation plots in Figure 7 we used randomly initialized MLP with the following configu- ration: hidden layers, 256 hidden units. The dataset was using 16 environments and batches of size 1024. The lines in Figure are linear least-squares regressions to the gradient data shown as scatter plots. We repeat the experiment 10 times with different nerwork weight seeds, resulting in the 10 regression lines. Zero gradients are excluded from the regression computation, as most gradients are masked out by the product mask in both cases.
"Therefore, is if the AND-mask has only 1s, and infinite if all components are masked out (which we then keep 0.)
20

---

Published as a conference paper at ICLR 2021
Baseline
DANN
IRM
AND-mask
Tost accuracy Training accuracy
1.00
0.75
0.50
1.00
0.75
0.50
10
50
10 Epoch
50
10 Epoch
50
1
10
50
Epoch
Epoch
Figure 14: Learning curves the evaluated methods. The top row shows the accuracy on the training set, the bottom row shows the accuracy on the test set.
B.4 FURTHER VISUALIZATIONS AND EXPERIMENTS
In Figure 1. we show how many environments need to be present for the baseline without AND-mask switch the decision boundary from the shorteuts the mechanism. Under the same experimental condition as in the main paper, the baseline first succeeds at 1024 environments.
Max. acouncy
1.0
Daselliee
Prod
0.5
16
32
64
128
256
512
1024
2048
4096
Training environments
Figure 15: Relationship between number of training environments and test accuracy for the AND-mask method compared to the baseline. We show the best performance out of five runs using the settings that were used for the experiment the main text.
B.5 SECTION 3.2 CIFAR-10 10 MEMORIZATION AND LABEL NOISE EXPERIMENTS
Memorization experiment In Figure 16 report the test performance (dashed lines) corresponding to the curves pre- sented in the main paper for the CIFAR-10 memorization experiment. The test performance with standard labels de- creases slower than the training performance as the threshold increases, and they eventually reach the same value. This is consistent with the hypothesis that by training on the consis- tent directions, the AND-mask selects the invariant patterns and prunes out the signals that are not invariant.
1.00
ANDaaa
Accuncies
Standand Labels
0.50
Randon
0.25
0,00
2.s 0.10
6.40 0.50
Agreement thresbold
Figure 16: Dashed lines show test acc, solid lines show training acc.
Network architecture and training details Each trial trains the ResNet "F ResNet" from the -yTocch-Ignite example for 80 epochs on the full CIFAR-10 training set. We use the Adam optimizer with learning rate 5e-4, and 0.1 learning rate decay at epoch 40 and 60. We fix the batch size to 80. We set up 14 trials by evaluating each of the AND-mask- makk--hresooldsss {0, 0.05, 0.1, 0.2, 0.4, 0.6, 0.8) for two datasets: (a) unchanged CIFAR- 10, (b) CIFAR-10 10 with the training labels replaced by random labels. Note that a threshold of corresponds to not using the AND-mask. Each trial is run twice with separate random seeds.
Label noise experiment We trained the same ResNet for the experiment above, once with and once without the AND-mask. We ran each experiment with three different starting learning rates
ci eifario/Fastreeneet.p
21

---

Published as a conference paper at ICLR 2021
(5e-4, 1e-3, 5e-3) and learning rate decay at epoch 60. The baseline worked best with learning rate 1e-3, while the AND-mast with 3.-3, likely to compensate for the masked out gradients. The AND-mask threshold that worked best 0.2, which is consistent with the results obtain in the experiment above.
B.6 SECTION 3.3 BEHAVIORAL CLONING ON COINRUN
The target policy π* is obtained by training PPO (Schulman al. 2017) for 400M time steps using the code To for the paper Cobbe et al. (2020). This policy is trained on the full distribution of levels in order to maximize its generality. We use x to generate behavioral cloning (BC) dataset, consisting of pairs (s, n (a)s)), where are the input-images (64 x 64 RGB) and π (a|s) is the discrete probability distribution over actions output by π*
The states are sampled randomly from trajectories generated by π² In order to test for generalization performance, the BC training dataset is restricted 64 distinct levels. We generate 1000 examples training level. The test set consists of 2000 examples, each from a different level which does not appear in the training set.
L
Figure 17: Screenshots of levels of CoinRun (from OpenAl).
A ResNet-18 tt is trained minimize the loss ( =o) We ran two automatic hyperparameter optimization studies using Tree-structured Parzen Estimation (TPE) (Bergstra et al.] (2013) of 1024
trials each, with and without the AND-mask. The learning rate was decayed by factor of 10 half-way at at 3/4 of the training epochs.
The "temporal" version of the AND-mask used for this experiment is reported in Algorithm
Algorithm 1: Temporal AND-mask Adam
m 31 + 81).g
V < v + 82) (gog)
a - selemiss__signe
Ba)
b - [[
s 0 - 0 - aam Vv
In blue we highlight the additional lines compared to traditional Adam. The threshold and }3 are hyperparameters that we included in the 1'024 trials of the search using Tree-structured Parsen Estimators. For the top 10 runs, hyperparameter values that were selected via the TPE search for the AND-mask are the following.
Table 3: Hyperparameters for the 5 best runs using the AND-mask, from the TPE search.
Test KL div
Ir
6
8g
weight decay
1.652e-2
0.0078
0.21
0.79
0.36
0.057
1.656e-2
0.0072
0.26
0.86
0.40
0.041
1.662e-2
0.0080
0.23
0.84
0.41
0.045
1 1.665e-2
0.0068
0.33
0.72
0.47
0.077
1.672e-2
0.0063
0.67
0.65
0.47
0.080
We found that applying weight decay as a second independent update after the AND-mask routine improved performance. To keep the comparison fair, we added this as switch in the hyperparameter search for the Adam baseline as well, and it improved performance there as well.
httpps: http:///tttub.ooooo
/ttaitraiinn n-procgen
22

---

Published as a conference paper at ICLR 2021
Adam AND-mask
Adam
10
3x10
AND-mask
Train Dxt
Test Dra
2 10
10"
15 Epoch
30
15
30
Epoch
Figure 18: Learning curves for the behavioral cloning experiment on CoinRun. Training loss is shown on the left, test loss is shown the right. We show the mean the top- 10 runs for each method. The shaded regions correspond to the 95% confidence interval of the mean hased on bootstrapping.
C APPENDIX TO SECTION 4
C.I RELATED WORK IN CAUSAL INFERENCE
Causal graphs and causal factorizations The formalization of causality through directed acyclic graphs (Pearl 2009) is key element informing exposition. According to such formalization, a causal model gives rise to each observed distribution. It is thereby possible to exploit properties of the causal factorization of the joint probability distribution over the observed variables. Clearly, there are many ways to factorize a joint distribution into conditionals; distinguishing feature of the causal factorization is that many of the conditionals, which we can think of as physical mechanisms underlying the statistical dependencies represented, are expected to remain invariant under interventions or changing external conditions. This postulate has appeared various forms in the literature (Haavelmo) 1943 Simon 1953 Hurwicz 1962 Pearl 2009. Schölkopf et al. 2012 17
Causal models and robust regression Based on this insight, it was proposed that regression based on causal features should presents desirable invariance and robustness properties (Mooij et al. 2009
Schölkopf et al.] 2012 Peters et al.] (0166) Rojas-Carulla et al. [018 [Heinze-Dem et al. 2018 von
Kügelgen et al. 2019; Parascandolo et al. (0188). this view, the mechanisms can be considered
as features of the patterns such that they support stable conditional probabilities. Thus learning the mechanisms may help achieve a stable performance across a number of conditions. Other works connecting causality and learning through invariances are (Subbaswamy et al.) 2019 Heinze- Deml
and Meinshausen] 2017), and perhaps most related to our work (Arjovsky et al. 2019) we
presented comparison with this method in the following section.
Causal regularization Recently Janzing 2019) showed that biasing learning towards models of lower complexity might in some cases be beneficial for a notion of generalization from observational to interventional regimes. Our proposed solution is however different, in that we only indirectly deal with penalizing model complexity, and rather focus on our proposed notion of consistency.
C.2 LEARNING INVARIANCES THE DATA
Here we are going to compare ILC to other approaches for learning invariances in the data with neural networks, and in particular to Invariant Risk Minimization (IRM) Arjovsky et al. (2019). The authors of IRM analyze a set up where minimizing training error might lead to models which absorb all the correlations found within the training data, thus failing to recover the relevant causal explanation. They consider multi-environment setting and focus on the objective of extracting data representations that lead to invariant prediction across environments.
While the high level objective is close to the one we focused on, the differences become clear when considering the definition of invariant predictors presented in Arjovsky et al. (2019):
This would he different for non-causal factorization of the joint distribution, Schölkopf 2019
23

---

Published as a conference paper at ICLR 2021
Definition 1. A data representation & : X - H. elicits invariant predictor o o across envi- ronments if there is a classifier w H - y simultaneously optimal for all environments, i.e., arg -y- [" ②) Ve E.
In particular, the objective minimized by IRM is:
min
Σ LEC
R (
A- Vo D)
(5)
where are the logits predicted by the neural network and w is a dummy scaling variable (see Arjovsky et al. (2019)). The relevant part is the penalty term A w1 - One way to interpret it, is that the penalty is large on every environment where the distribution outputted by could be made 'closer' to the distribution of the labels by either sharpening (w 1) softening (i.e., closer to uniform w 1).
Let us consider the example from IRM, where the authors deseribe two datasets of images that each contain either a cow or a camel: In one of the datasets, there is grass on 80% of the images with cows, while in the other dataset there is grass 90% of them. IRM then makes the point that can learn to ignore grass The setting we consider in this paper is slightly different: take our example from the CIFAR-10 10 experiments. Under our concept of invariance, we expect that (depending on the data generating process) even a single dataset where we treat every image as coming from its own 'environment' should be sufficient to discover invariances. Drawing connection to the setting from IRM, we would argue that the second dataset should not be necessary to learn that 'grass' is not 'cow'. If one treats every example as coming from its own environment, there is already sufficient information in the first dataset to realize that cows are not grass: Grass is predictive of cows only in 80% of the data, so grass cannot be "cow'. The actual cow the other hand, should be present in 100% of the images, and as such it the invariance we are looking for. Note that this is course a much more strict definition of within them,
feature, because its correlation with the label cow is inconsistent (80% vs 90%).
invariance: If our dataset contains images labeled as 'cows' but that have might start to discard the features of cows as well.
24


Reviews:
[{"review_id": "bUd_-ZUmbqI", "reviewer": "AnonReviewer1", "summary": "", "questions": "", "limitations": "", "rating": 9, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "", "summary_of_the_paper": "", "summary_of_the_review": "", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "The authors introduce and formalize the concept of Invariant Learning Consistency (ICL), which is motivated by the idea that \"good explanations are hard to vary\" in the context of deep learning. Instead of using the arithmetic mean to pool gradients (logical OR), the authors propose to use the element-wise geometric mean of gradients with a logical AND masking. Experimental results on both synthetic and real-world data sets are reported under the setup of supervised learning and reinforcement learning. \n\nThis paper is well written and clearly presented. The exploration of using geometric mean with a logical AND masking to pool gradients in deep learning is very interesting and novel. The proposed method learns invariances in gradient-based optimizations and can help with the memorization issue. This work has made good efforts towards a better understanding of learning, memorization and generalization of OOD. Experimental results on both synthetic and real-world data sets have demonstrated the effectiveness of the proposed AND-mask, comparing with commonly used regularizers and several baselines. \n\nAs the authors point out, the AND-mask is one of multiple possible ways to improve consistency, and it is unlikely to be a practical algorithm for all applications. It would be great if the authors can provide further insights on what kind of data distributions (or applications) could potentially benefit from the proposed method versus using the arithmetic mean. In addition, it would be interesting to explore hybrid methods that combine the advantages of pooling gradients using arithmetic mean and geometric mean (i.e., AND-mask).", "extra_scores": {}, "extra_text": {}}, {"review_id": "XB5zTIGSxjK", "reviewer": "AnonReviewer4", "summary": "", "questions": "", "limitations": "", "rating": 7, "confidence": 3, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "", "summary_of_the_paper": "", "summary_of_the_review": "", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "This paper investigates one possible pitfall of current gradient descent method that averaging gradients over different examples failed to capture the invariance between different examples, through it can learn quickly by memorizing data. The authors claim that this is one important reason that machine learning with GD can't generalize well to out of domain dataset. To solve this issue, this paper focus on developing a method to learning the invariant explanations. The authors firstly formalize the a notion of consistency of the loss surface and also propose a practical algorithm, AND-mask. The authors also carried experiments and analysis on synthetic dataset to validate the effective the method. Overall, the work is important and the paper is well presented. I vote for accepting. \n\n\n##########################################################################\nPros \n\t1. The paper studied the important problem of model generalization. The paper is well motivated and the knowledge presented can benefit the community. \n\t2. The paper defines the invariance as the consistency for minima of the loss surface. The author presented case study examples as well as math formulations. The presentation is clear and easy to understand.\n\t3. The authors validate the value of capturing invariance through the implementation of a practical AND-mask, and run experiment on a set of tasks. The baselines are reasonably chosen. The proposed method greatly outperforms other baselines. \n\t4. The synthetic tasks unveil the difference between ILC and gradient averaging. It is very helpful for the readers. \n\n##########################################################################\nCons\n\t1. The work claim that they run experiments on a set of real-world tasks. The authors introduce artificial label noisiness in CIFAR-10 by randomly shuffling the labels. However, recently work (e.g https://arxiv.org/pdf/2001.10528.pdf) found that noisiness exists in many popular datasets. It would be interesting to show that ILC can also handle such naturally introduced noises. \n2. What is the connection between invariance and model casual explanation?", "extra_scores": {}, "extra_text": {}}, {"review_id": "J_z40-zjvpp", "reviewer": "AnonReviewer2", "summary": "", "questions": "", "limitations": "", "rating": 2, "confidence": 3, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "", "summary_of_the_paper": "", "summary_of_the_review": "", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "this work posits that invariant mechanisms exist in a dataset. a machine learning algorithm that is trained using gradient descent usually averages gradients across examples. the thesis is that by averaging gradients, information is lost. the method posits that in a gradient descent algorithm, instead of an arithmetic average, a geometric (or karcher) mean can be used to preserve information about invariant mechanisms - while ignoring confounders. there are difficulties in a straightforward application of the geometric mean, so a simple heuristic algorithm is developed, involving masking gradients depending on whether the sign of the gradient agrees across a batch of examples (or, whether some agreement threshold is reached). this algorithm is tested on a synthetic dataset, a semi-synthetic task on CIFAR-10, and coinbase, an RL algorithm. \n\nrecommend major revisions and baselines. it is interesting ideas and it would do the ideas justice to put a lot of effort into a rewrite so the ideas are properly understood by the ICLR community. clarity needs to be significantly improved in the introduction and conceptual framing (mainly in intro/methods sections)—the rest of the paper is largely well-written, the experiments are well-documented in the appendix, relationship to invariant risk minimization and causality is documented in appendix.\n\nbaselines: sum vs geometric mean is a well-known effect in products of experts vs sums of experts work. i think this should be the right baseline to compare to. train separate classifiers and use them as a product of experts, and you should get the same performance as in this paper. definitely need to discuss this related work and how learning consistency /geometric mean measures differ and warrant comparison.\n\nthe writing is more difficult to read than it ought to be. more work is needed to re-use existing concepts. for example, consistency is overloaded here (it might confuse some readers from a statistics background). the paper's title has the concepts of varying and explanations (variance and explanations do not appear in the method). small things like this abound. trying to find specific examples where i have a strong opinion to help:\n\n* instead of consistency, it may be worth spending some time to think of another word that is less confusing. congruence? concordance? 'learning invariant mechanisms with geometric mean gradient descent' is an example of a title that would be easier to understand: (1) mechanisms relates to prior work such as the pearl work that is cited (indeed, in the appendix the authors state 'causality... is a key element informing our exposition'). a causal mechanism is a well-known concept to the ICLR community. (2) concordance is still overloaded (e.g. this is a major concept in biostatistics) but not to the degree that consistency is. similarly, if you choose congruence, this could have the nice geometric interpretation in the hessian example that is helpful for understanding the work in figure 3.\n\n* the david deutsch quote distracts and confuses, remove it (i also know some researchers that might be immediately skeptical of a david deutsch citation in an ICLR paper). see above for ideas on title changes.\n\n* the first example is helpful to understand the goals of the paper. however, figure 1 --  the symbol with the plus sign and arrow is confusing, all the axes tick labels need to be much larger\n\n* the 'an example' chess example in the gray box on page 2 is unnecessary and distracting. instead, the discussion of the relationship to arjovsky et al could be inserted (with grass and cows), which is much more interesting and useful to a reader. \n\n* equation 1 engenders a double negative throughout the conceptual framing of the paper. i highly suggest considering renaming this to a 'consistency' score to reflect the name of the method; this will make it easier for readers to understand. \n\n* 'patchwork' may be another jargon word, try to find another one that is easier to understand. on page 3: 'low consistency of a classic patchwork solution' is loaded with jargon. first, a patchwork solution is not defined here or in previous work. second, a 'classic patchwork' solution is more confusing. removing adjectives such as 'classic' or even 'patchwork' throughout the paper may help readability and clarity. \n\n* i found the synthetic memorization dataset very difficult to understand. never start a sentence with math like p(y | x_{d_M}), it looked like it was connected to the previous with a \\cdot. ideally write out the functional form of the mechanism. the axes in figure 5 are not labeled, so i have a hard time understanding what we are looking at: are the x and y axes d_S or d_M? how is environment A vs environment B defined? \n\n* re: wording -- ideally delete shortcuts. do not introduce more unnecessary lingo, because it leads to sentences like 'the shortcuts are not shared across environments, but provide a simple way to classify the data, even when pooling all the environments together'. this is asking a reader to do a lot of work: (1) what is pooling? this has a standard usage. (2) what are environments? this is used in RL (3) what are shortcuts, and how do they relate to environments? trying to rewrite this, i would want something with fewer novel concepts, that focuses on mechanisms that are invariant across datapoints or groups of datapoints (groups of data arising from causal graphs, e.g. in causal inference terminology).\n\n* extremely minor, a few typos and inconsistent capitalization (section 3.1 is not capitalized, figure titles not capitalized, paragraph headings, figure legends not capitalized , good to pick one and stick to it)", "extra_scores": {}, "extra_text": {}}, {"review_id": "GP4glD0T8I", "reviewer": "AnonReviewer3", "summary": "", "questions": "", "limitations": "", "rating": 5, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "", "summary_of_the_paper": "", "summary_of_the_review": "", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "The authors attempt to recover invariant solutions, defined as those with a similar loss neighbourhood across environments. This concept is interesting, especially since it can be incorporated with a clever understanding of loss gradients and hessians which underlies the generality of the proposed approach. \n\nThe presentation is puzzling to me. The objective for all intents and purposes is to recover the causal solution from data in multiple environments, but this is never explicitly mentioned even though causality is said to be a \"key element\" in the Appendix. In this area, also precise conditions are needed on data distributions from different environments which seem to play no role in this paper. A more thorough description of what can be expected from invariant solutions and when we are expected to consistently recover them is needed in my opinion. The introduction is therefore also vague, what do we mean by generalizing out-of-sample? Is the objective to ensure good performance with arbitrary shifts in distribution while maintaining a causal graph? Is there an assumption that the invariant mechanism is unique among available environments?\n\nRegarding the ILC, hessians and gradients I do see they are related but it is not lear to me how changing hessians would lead to optimizing for the ILC. The ILC is defined with respect to all local minima, I am not sure how such an objective would be attainable. More details here would be helpful.\n\nIn general, I found all experiments highly constructed and nothing like what you'd expect to see in reality. If the objective is improved performance out-of-sample, why not evaluate the method on domain generalization tasks (office, caltech datasets, etc.)? Invariant solutions may also be defined as minimizing a worst-case optimization problem across environments, yet the robust optimization literature is not mentioned.\n\nMinor comments:\n- I may be misunderstanding, but as described in the Appendix, does the synthetic experiment have shortcuts for both labels sampled from the same distribution?\n- With unobserved confounding, it is known that the causal solution does not have zero loss gradient (for example in a linear model, least squares returns biased parameter estimates), what can we expect in that case?\n\n\nIn summary, I do believe the proposed approach to be interesting but the context in which it is expected to work, as well as its relationships with causality, robust optimization and domain generalization are not well described; this prevents me from raising my score at this moment. ", "extra_scores": {}, "extra_text": {}}]

Author rebuttal:

Meta-review: The paper shows that hat if the goal is to find invariant mechanisms in the data, these can be identified by finding explanations (e.g. model parameters) that are hard to vary across examples. To find those "explanations" it then proposes to combine gradients across examples in a "logical AND" fashion, i.e., pooling gradients sing a geometric mean with a logical AND masking. All reviewers agree that the direction is very interesting. While indeed mentioning sum and products of experts might be good, the overall idea is still very much interesting, also to the ICRL community, since it paves the way to apply this to larger set of machine learning methods, as actually shown in the experimental evaluation. Still, the authors should make the link to causality more obvious from the very beginning. This should also involve clarifying that "explanations" here do not refer to "explanations" as used in Explainable AI. Overall, this is an interesting and simple (in a positive sense) contribution to the question of getting at least "more" causal models. 
Decision: Accept (Poster)