This repository contains the implementation of our margin-loss based model.
Almost all flags can be set at utils/config.py. The dataset paths, the hyperparams can be set accordingly in this
file.
- GPU: One NVIDIA GeForce RTX 2080 Ti
- RAM: 4GB (approx) if the features are explicitly extracted inside the model, 1.5GB otherwise
- CPU: AMD Ryzen Threadripper 3960X 24-Core Processor
- OS: Ubuntu 18.04.6 LTS
We used 3 random seeds to run the final models: 2411, 5193, 4594
- Download the CelebA, and Waterbirds datasets. Extract their features from a pretrained feature extractor and store them. Note the folder path and update it in
utils/config.py. Recall that the validation set has to be group-balanced. For CelebA, store the folder in theceleba_pathattribute ofutils/config.py(similarly for Waterbirds). The embeddings should be stored in{split}_feats.npy, whereas the bias and target labels should be stored in{split}_bias.npyand{split}_target.npyrespectively, inside the folder.
To run the baseline (ERM model), run the following command. Dataset can either be waterbirds or celeba:
python margin_loss.py --dataset waterbirds --train --type baseline --bias python margin_loss.py --dataset waterbirds --train --type marginpython margin_loss.py --dataset waterbirds --val-only [or test-only]python margin_loss.py --dataset waterbirds --clusteringCheckpoints of ERM and our model are provided in erm_path and margin_path. These can be used to validate the scores reported in our paper.
| Model | Waterbirds | CelebA | ||
|---|---|---|---|---|
| Worst | Average | Worst | Average | |
| ERM | 38.90 | 76.22 | 27.20 | 75.43 |
| DebiAN | 58.94 | 80.47 | 26.10 | 75.41 |
| BPA | 58.70 | 80.83 | 66.71 | 84.14 |
| LfF | 66.09 | 81.39 | 13.26 | 69.42 |
| JTT | 49.84 | 77.03 | 56.25 | 73.58 |
| GEORGE | 59.35 | 80.34 | 42.22 | 79.76 |
| Ours | 80.29 | 84.56 | 81.61 | 86.04 |