PyTorch code to run synthetic experiments.

Overview

Code repository for Invariant Risk Minimization

Source code for the paper:

@article{InvariantRiskMinimization,
    title={Invariant Risk Minimization},
    author={Arjovsky, Martin and Bottou, L{\'e}on and Gulrajani, Ishaan and Lopez-Paz, David},
    journal={arXiv},
    year={2019}
}

Repository licensed under LICENSE.

Comments
  • Different implementation in Colored MNIST

    Different implementation in Colored MNIST

    Hi author,

    Thanks for your wonderful work. I am confused about the implementation of the squared gradient norm. In the paper, you use X^{e,i} and X^{e,j} to compute the squared gradient norm, where X^{e,i} and X^{e,j} are two random minibatches. However, it seems that the squared gradient norm is computed with the use of X^{e,i}, and X^{e,i} in colored MNIST. Do these two kinds of implementation work in the same way?

    Best regards, Qing LIAN

    opened by lianqing11 2
  • question about batch implementation of IRM loss

    question about batch implementation of IRM loss

    Hi,

    Thanks for the great work! I am trying to reproduce some results and have a question regarding batch implementation of IRM loss. In Section 3.2 and Appendix D, you suggest to use following to do batch implementation:

    def compute_penalty(losses, dummy_w):
        g1 = grad(losses[0::2].mean(), dummy_w, create_graph=True)[0] 
        g2 = grad(losses[1::2].mean(), dummy_w, create_graph=True)[0]
        return (g1 * g2).sum()
    

    I am wondering whether we can do following:

    def compute_penalty(losses, dummy_w):
        g = grad(losses.mean(), dummy_w, create_graph=True)[0] 
        return (g ** 2).sum()
    

    You mentioned that the former one is "unbiased estimate of the squared gradient norm", but I am not sure why it is the case. If you can provide some explanation, that would be great.

    Thank you!

    opened by weiHelloWorld 1
  • Question about the Colored MNIST

    Question about the Colored MNIST

    Hi author,

    Thanks for your wonderful work. But I am confused why "obtain the final label y by flipping ~y with probability 0.25". Without this, IRM may get no better than ERM?

    opened by TongZhangTHU 1
  • Non-causal errors for scrambled samples

    Non-causal errors for scrambled samples

    Hi,

    I tried to reproduce Fig. 4 from the paper, the noncausal panels for the cases with scrambling (FOS, FES, POS, PES) are empty. The reason is that the noncausal variables are identified by finding zero weights here, but after scrambling these are removed. I think the errors should be determined by applying the scrambling on the model weights first. Obviously the figure in the paper does contain graphs, could you be so kind to update the code you used? Thank you!

    opened by stefan-schroedl 1
  • Some question about IRM.

    Some question about IRM.

    Hi lopezpaz, IRM is a fantastic work and I am reading and trying to reproduce it. But I meet some questions.

    1. When it comes to the colored MINIST experiment. The paper says it divides the MINIST into 3 environments and colors the images to red and green. So Does it mean the test environment also contains digits of the same color in the training set? I mean, suppose that there are digits 9 with green color, and the test set also contains this kind of images?

    2. Can IRM solve multiple classification problems? If yes, should I replace binary loss with cross-entropy loss?

    I am looking forward to you reply! Thanks.

    opened by bigMaxM 0
Owner
Facebook Research
Facebook Research
SciKit-Learn Laboratory (SKLL) makes it easy to run machine learning experiments.

SciKit-Learn Laboratory This Python package provides command-line utilities to make it easier to run machine learning experiments with scikit-learn. O

ETS 528 Nov 25, 2022
A general framework for deep learning experiments under PyTorch based on pytorch-lightning

torchx Torchx is a general framework for deep learning experiments under PyTorch based on pytorch-lightning. TODO list gan-like training wrapper text

Yingtian Liu 6 Mar 17, 2022
Official PyTorch implementation of "Proxy Synthesis: Learning with Synthetic Classes for Deep Metric Learning" (AAAI 2021)

Proxy Synthesis: Learning with Synthetic Classes for Deep Metric Learning Official PyTorch implementation of "Proxy Synthesis: Learning with Synthetic

NAVER/LINE Vision 30 Dec 6, 2022
Implement Decoupled Neural Interfaces using Synthetic Gradients in Pytorch

disclaimer: this code is modified from pytorch-tutorial Image classification with synthetic gradient in Pytorch I implement the Decoupled Neural Inter

Andrew 114 Dec 22, 2022
Commonality in Natural Images Rescues GANs: Pretraining GANs with Generic and Privacy-free Synthetic Data - Official PyTorch Implementation (CVPR 2022)

Commonality in Natural Images Rescues GANs: Pretraining GANs with Generic and Privacy-free Synthetic Data (CVPR 2022) Potentials of primitive shapes f

null 31 Sep 27, 2022
Code and data of the ACL 2021 paper: Few-Shot Text Ranking with Meta Adapted Synthetic Weak Supervision

MetaAdaptRank This repository provides the implementation of meta-learning to reweight synthetic weak supervision data described in the paper Few-Shot

THUNLP 5 Jun 16, 2022
Code release for our paper, "SimNet: Enabling Robust Unknown Object Manipulation from Pure Synthetic Data via Stereo"

SimNet: Enabling Robust Unknown Object Manipulation from Pure Synthetic Data via Stereo Thomas Kollar, Michael Laskey, Kevin Stone, Brijen Thananjeyan

null 68 Dec 14, 2022
Experiments with differentiable stacks and queues in PyTorch

Please use stacknn-core instead! StackNN This project implements differentiable stacks and queues in PyTorch. The data structures are implemented in s

Will Merrill 141 Oct 6, 2022
PyTorch Personal Trainer: My framework for deep learning experiments

Alex's PyTorch Personal Trainer (ptpt) (name subject to change) This repository contains my personal lightweight framework for deep learning projects

Alex McKinney 8 Jul 14, 2022
PyTorch experiments with the Zalando fashion-mnist dataset

zalando-pytorch PyTorch experiments with the Zalando fashion-mnist dataset Project Organization ├── LICENSE ├── Makefile <- Makefile with co

Federico Baldassarre 31 Sep 25, 2021
PyTorch implementation of the supervised learning experiments from the paper Model-Agnostic Meta-Learning (MAML)

pytorch-maml This is a PyTorch implementation of the supervised learning experiments from the paper Model-Agnostic Meta-Learning (MAML): https://arxiv

Kate Rakelly 516 Jan 5, 2023
PyTorch framework, for reproducing experiments from the paper Implicit Regularization in Hierarchical Tensor Factorization and Deep Convolutional Neural Networks

Implicit Regularization in Hierarchical Tensor Factorization and Deep Convolutional Neural Networks. Code, based on the PyTorch framework, for reprodu

Asaf 3 Dec 27, 2022
Applications using the GTN library and code to reproduce experiments in "Differentiable Weighted Finite-State Transducers"

gtn_applications An applications library using GTN. Current examples include: Offline handwriting recognition Automatic speech recognition Installing

Facebook Research 68 Dec 29, 2022
Code to reproduce the experiments in the paper "Transformer Based Multi-Source Domain Adaptation" (EMNLP 2020)

Transformer Based Multi-Source Domain Adaptation Dustin Wright and Isabelle Augenstein To appear in EMNLP 2020. Read the preprint: https://arxiv.org/a

CopeNLU 36 Dec 5, 2022
Code to reproduce experiments in the paper "Explainability Requires Interactivity".

Explainability Requires Interactivity This repository contains the code to train all custom models used in the paper Explainability Requires Interacti

Digital Health & Machine Learning 5 Apr 7, 2022
Code to reproduce the experiments from our NeurIPS 2021 paper " The Limitations of Large Width in Neural Networks: A Deep Gaussian Process Perspective"

Code To run: python runner.py new --save <SAVE_NAME> --data <PATH_TO_DATA_DIR> --dataset <DATASET> --model <model_name> [options] --n 1000 - train - t

Geoff Pleiss 5 Dec 12, 2022
Source code and notebooks to reproduce experiments and benchmarks on Bias Faces in the Wild (BFW).

Face Recognition: Too Bias, or Not Too Bias? Robinson, Joseph P., Gennady Livitz, Yann Henon, Can Qin, Yun Fu, and Samson Timoner. "Face recognition:

Joseph P. Robinson 41 Dec 12, 2022
Minimal diffusion models - Minimal code and simple experiments to play with Denoising Diffusion Probabilistic Models (DDPMs)

Minimal code and simple experiments to play with Denoising Diffusion Probabilist

Rithesh Kumar 16 Oct 6, 2022
The LaTeX and Python code for generating the paper, experiments' results and visualizations reported in each paper is available (whenever possible) in the paper's directory

This repository contains the software implementation of most algorithms used or developed in my research. The LaTeX and Python code for generating the

João Fonseca 3 Jan 3, 2023