This repository contains the code to reproduce the experiments from the paper "On the Effect of Gradient Regularisation on Interpretability".
The required packages and their versions are listed in requirements.txt
(TODO: Add package versions).
The dataset-model combination is determined by an input argument --dataset_model
. The available options are:
Dataset | Model | Argument Value |
---|---|---|
MNIST | LeNet | MNIST_LeNet |
MNIST | ResNet | MNIST_ResNet |
Fashion-MNIST | LeNet | FMNIST_LeNet |
KMNIST | LeNet | KMNIST_LeNet |
CIFAR-10 | ResNet | CIFAR_ResNet |
Imagenette | ResNet | Imagenette_ResNet |
All input and output files are stored relative to the path specified with the --data_root
argument.
To train models with varying regularisation strengths, run the following command:
python main.py --dataset_model <DATASET_MODEL>
Replace <DATASET_MODEL>
with one of the values from the table above.
To evaluate saliency metrics, run:
python saliency.py --dataset_model <DATASET_MODEL> --saliency_method <SALIENCY_METHOD>
Replace <SALIENCY_METHOD>
by the method that should be used. Method names are defined by the quantus package: Saliency
for the input gradient and DeepLift
for DeepLift.
To generate plots of the metrics specified in USED_METRICS
, use:
python plot_saliency.py --dataset_model <DATASET_MODEL> --saliency_method <SALIENCY_METHOD>
Replace <DATASET_MODEL>
with one of the valid dataset-model options.
To generate the p-values to test whether the faithfulness estimate is actually increasing, the following can be run after the metrics have been calculated:
python p_value.py