Skip to content

ServiceNow/beyond-trivial-explanations

Repository files navigation

ServiceNow completed its acquisition of Element AI on January 8, 2021. All references to Element AI in the materials that are part of this project should refer to ServiceNow.

Beyond Trivial Counterfactual Explanations with Diverse Valuable Explanations

Accepted at ICCV2021 [Paper]

0. Download the Dataset

  • Images
  • Labels
  • Uncompress them into a path of your choice. Assuming that $DATA corresponds to the path where celebA has been placed, move ./data/celeba_meta into $DATA.
  • Note that our oracle is based on the VGG_Faces2 ResNet-50-128D. You need to download it and put it in ./data

1. Install requirements

pip install -r requirements.txt

2. Generate counterfactuals for pre-trained models

You will need to download the pre-trained models from Zenodo

  1. Decompress pre-trained models in $DATA (e.g. ./data)
  2. Run the BTE experiment:
python trainval.py -e random_search -sb ./logs/bte -d ./data -r 1
  1. Run notebooks/Gather Results.ipynb

3 (optional). Train from scratch

To run an experiment you will need to call:

python trainval.py -e tcvae -sb ./logs -d ./data -r 1

Where the argument descriptions are:

-e  [Experiment group to run like 'vae' (the rest of the experiment groups are in exp_configs/main_exps.py)] 
-sb [Directory where the experiments are saved]
-r  [Flag for whether to reset the experiments]
-d  [Directory where the datasets are saved]

To reproduce the results you will need to run:

python trainval.py -e tcvae -sb ./logs/tcvae -d ./data -r 1
python trainval.py -e vae -sb ./logs/vae -d ./data -r 1
python trainval.py -e oracle -sb ./logs/oracle -d ./data -r 1
python trainval.py -e unbiased_classifier -sb ./logs/classifier -d ./data -r 1

This will train all the generators and classifiers needed to reproduce the experiments. Then, assuming you only ran one hyperparameter combination per model (so there is only one folder inside ./logs/tcvae/, etc, run:

mv ./logs/tcvae/* ./data/pretrained_models/tcvae
mv ./logs/vae/* ./data/pretrained_models/xgem+
mv ./logs/oracle/* ./data/pretrained_models/oracle
mv ./logs/unbiased_classifier/* ./data/pretrained_models/unbiased_classifier

Finally, run the BTE experiment:

python trainval.py -e cache_fim -sb ./logs/bte -d ./data -r 1
python trainval.py -e random_search -sb ./logs/bte -d ./data -r 1

You can plot the results by running the Jupyter notebook in notebooks/Gather Results.ipynb

3. Visualize Intermediate Results

Follow these steps to visualize plots. Open results.ipynb, run the first cell to get a dashboard like in the gif below, click on the "plots" tab, then click on "Display plots". Parameters of the plots can be adjusted in the dashboard for custom visualizations.

Cite

@article{rodriguez2021beyond,
  title={Beyond Trivial Counterfactual Explanations with Diverse Valuable Explanations},
  author={Rodriguez, Pau and Caccia, Massimo and Lacoste, Alexandre and Zamparo, Lee and Laradji, Issam and Charlin, Laurent and Vazquez, David},
  journal={arXiv preprint arXiv:2103.10226},
  year={2021}
}

About

Beyond Trivial Counterfactual Explanations with Diverse Valuable Explanations is a ServiceNow Research project that was started at Element AI.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published