Git Product home page Git Product logo

dgvgs's Introduction

Domain Generalization via Gradient Surgery

This repository contains the source code corresponding to the paper "Domain Generalization via Gradient Surgery" (ICCV 2021). You can check out our paper here: https://arxiv.org/abs/2108.01621.

Instructions

This project uses Python 3.8.10 and PyTorch 1.10.0.

Data:

  1. Download the PACS (Li et al., 2017), VLCS (Fang et al., 2013) and Office-Home (Venkateswara et al., 2017) datasets and put them in data/raw/.
  2. Resize images and generate training, validation and test splits. Run ./00_prepare_data.sh after installing the project environment (instructions below).

Project environment:

  1. Create and activate virtual environment: 1) python3 -m venv env, 2) source env/bin/activate
  2. Install required packages: pip install -r requirements.txt
  3. Install project modules (src): pip install -e .

Simulations:

To run simulations across all datasets (PACS, VLCS and Office-Home) and methods (Deep-All, Agr-Sum, Agr-Rand and PCGrad), execute ./01_run_trials.sh.

If you want to run a particular combination of dataset and method, use the train_model.py script. For example, the following instruction:

python scripts/train_model.py \
    --data_dir=data/processed \
    --results_dir=results/train \
    --dataset=PACS \
    --method=deep-all

will run Deep-All on PACS and save the results in results/train.

Reference

  • Mansilla, L., Echeveste, R., Milone, D. H., & Ferrante, E. (2021). Domain generalization via gradient surgery. In Proceedings of the IEEE/CVF International Conference on Computer Vision (pp. 6630-6638).

License

MIT

dgvgs's People

Contributors

lucasmansilla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dgvgs's Issues

Does it support multi-gpu training?

Hi there, thanks for this nice work! Your code looks very neat and clear. However, when I am trying gradient surgery on my own task, where 4 GPUs are utilized to load 4 source datasets, the error throws AttributeError: 'DataParallel' object has no attribute 'get_grads '. So I am wondering this may be caused by the multi-GPU training process. Can you kindly elaborate on this? How many GPUs do you use in your experiments? Thanks!

The problem about PCGrad

The results of PCGrad reported in Table 1. seems to be similar to baseline. And the averge gradient cosine similarity shown in Fig 2. are all greater than 0, will this be the reason why PCGrad does not work?

The link of PACS Dataset failed

Hi! Thanks for sharing the work! But the link of PACS Dataset failed. Could you update the download link of PACS! Thank u

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.