Code repository for Contrastive Corpus Attribution for Explaining Representations.
- Git clone or download this repository.
cd cl-explainability
.- Create and activate the specified conda environment by running
conda env create -f environment.yml conda activate cl-explain-env
- Install the
cl_explain
package and the necessary dependencies for development by runningpip install -e ".[dev]"
.
Modify global constants in scripts/constants.py
for paths where the image data,
encoder models, and results are stored.
- To train a ResNet18 model for MURA, execute
python scripts/train_classifier.py
. Runpython scripts/train_classifier.py --help
to see how to use each command line argument. Please see our paper for how to obtain a trained SimCLR model for ImageNet and a trained SimSiam model for CIFAR-10. - To run feature attributions, execute
python scripts/attribute.py
. Runpython scripts/attribute.py --help
to see how to use each command line argument. - To evaluate feature attributions, execute
python scripts/eval.py
. Runpython scripts/eval.py --help
to see how to use each command line argument.