Fishr: Invariant Gradient Variances for Out-of-Distribution Generalization

Alexandre Rame, Corentin Dancette, Matthieu Cord
9/7/2021
297 citations
cs.LGcs.AIcs.CV

Official code: alexrame/fishr (90 stars, Python, GPL-3.0, last commit 2022-05-25). Most starred: facebookresearch/DomainBed, a community implementation (1,630 stars, Python, MIT, last commit 2025-12-16, 18× the official stars). 1 more implementation below.

Abstract

Learning robust models that generalize well under changes in the data distribution is critical for real-world applications. To this end, there has been a growing surge of interest to learn simultaneously from multiple training domains - while enforcing different types of invariance across those domains.

Show full abstract

Yet, all existing approaches fail to show systematic benefits under controlled evaluation protocols. In this paper, we introduce a new regularization - named Fishr - that enforces domain invariance in the space of the gradients of the loss: specifically, the domain-level variances of gradients are matched across training domains. Our approach is based on the close relations between the gradient covariance, the Fisher Information and the Hessian of the loss: in particular, we show that Fishr eventually aligns the domain-level loss landscapes locally around the final weights. Extensive experiments demonstrate the effectiveness of Fishr for out-of-distribution generalization. Notably, Fishr improves the state of the art on the DomainBed benchmark and performs consistently better than Empirical Risk Minimization. Our code is available at https://github.com/alexrame/fishr.

View on arXivView PDF

Code Implementations(2)

Code implementations of this paper
RepositoryTypeStarsLanguageLicenseLast commit
alexrame/fishrOfficial90PythonGPL-3.02022-05-25
facebookresearch/DomainBedCommunity1,630PythonMIT2025-12-16
alexrame/fishrOfficial100%
GPL-3.0

Official PyTorch implementation of the Fishr regularization for out-of-distribution generalization

908PythonSep 6, 20214 years agoGPL-3.0
MIT

DomainBed is a suite to test domain generalization algorithms

1,630332Python, TeXJun 29, 202011 months agoMIT

Similar Papers

Cite this paper

@article{rame2021fishr,
  title  = {Fishr: Invariant Gradient Variances for Out-of-Distribution Generalization},
  author = {Alexandre Rame and Corentin Dancette and Matthieu Cord},
  year   = {2021},
  eprint = {2109.02934},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2109.02934}
}

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/2109.02934.svg)](https://codeofpaper.com/paper/2109.02934)

Discussion