SAND-mask: An Enhanced Gradient Masking Strategy for the Discovery of Invariances in Domain Generalization

Soroosh Shahtalebi, Jean-Christophe Gagnon-Audet, Touraj Laleh, Mojtaba Faramarzi, Kartik Ahuja +1 more
6/4/2021
79 citations
cs.LGcs.AI

Official code: facebookresearch/DomainBed (1,630 stars, Python, MIT, last commit 2025-12-16). 1 more implementation below.

Abstract

A major bottleneck in the real-world applications of machine learning models is their failure in generalizing to unseen domains whose data distribution is not i.i.d to the training domains. This failure often stems from learning non-generalizable features in the training domains that are spuriously correlated with the label of data.

Show full abstract

To address this shortcoming, there has been a growing surge of interest in learning good explanations that are hard to vary, which is studied under the notion of Out-of-Distribution (OOD) Generalization. The search for good explanations that are \textit{invariant} across different domains can be seen as finding local (global) minimas in the loss landscape that hold true across all of the training domains. In this paper, we propose a masking strategy, which determines a continuous weight based on the agreement of gradients that flow in each edge of network, in order to control the amount of update received by the edge in each step of optimization. Particularly, our proposed technique referred to as "Smoothed-AND (SAND)-masking", not only validates the agreement in the direction of gradients but also promotes the agreement among their magnitudes to further ensure the discovery of invariances across training domains. SAND-mask is validated over the Domainbed benchmark for domain generalization and significantly improves the state-of-the-art accuracy on the Colored MNIST dataset while providing competitive results on other domain generalization datasets.

View on arXivView PDF

Code Implementations(2)

Code implementations of this paper
RepositoryTypeStarsLanguageLicenseLast commit
facebookresearch/DomainBedOfficial1,630PythonMIT2025-12-16
shahtalebi/SAND-maskOfficial1PythonMIT2021-06-16
MIT

DomainBed is a suite to test domain generalization algorithms

1,630332Python, TeXJun 29, 202011 months agoMIT
MIT
10Python, TeXJun 16, 20215 years agoMIT

Similar Papers

Cite this paper

@article{shahtalebi2021sandmask,
  title  = {SAND-mask: An Enhanced Gradient Masking Strategy for the Discovery of Invariances in Domain Generalization},
  author = {Soroosh Shahtalebi and Jean-Christophe Gagnon-Audet and Touraj Laleh and Mojtaba Faramarzi and Kartik Ahuja and Irina Rish},
  year   = {2021},
  eprint = {2106.02266},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2106.02266}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2106.02266.svg)](https://codeofpaper.com/paper/2106.02266)

Discussion