Explainability and interpretability play an important role for adopting deep neural networks. Through analyzing the effect of path interventions at various nodes on model's performance, we are able to reveal the causal mechanisms within hidden layers and isolate the relevant components from noisy ones.
This repository contains the material used to obtain the results in our paper with LeNet trained on the MNIST dataset.
Install python 3:
sudo apt update
sudo apt install python3
sudo apt install python3-pipInstall poetry :
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -- Clone the repo and go at the root
git clone https://github.com/annonym/ixnn.git && cd ixnn
- Setup poetry
poetry install # The next part is to setup jupyter with poetry poetry run jupyter contrib nbextension install --user poetry run jupyter nbextensions_configurator enable --user poetry run ipython kernel install --user --name=explainnn
To launch the main script simply run
poetry run python src/explainnn/main.pyA step by step demonstration is available in the jupyter-notebook
config.yaml contains all the parameters for the main script :
device: wether to run the script on CPU or GPU (⚠️ : if you want to use the GPU you have to install PyTorch alongside CUDA, see : https://pytorch.org/get-started/locally/)dataset_name: the name of the dataset to usemodel_name: the name of the model to uselearn_explainer: wether to generate the causal graph or nottarget_idx: the index of the targeted classn_samples: the number of samples used to generate the causal graphsoft_interventions: soft or hard interventionsgraph_stab: wether to test graph stabilitygen_attr: wether to generate attributionssave_attr: wether to save the generated attributionsvis_attr: wether to plot the attributionseval_attr: wether to generate the metrics filebaseline_attr: wether to plot the baseline methods attributionslayer_name: the name of the layer used to generate attributionslayer_name_soft: the name of the layer used to test graph stability
For evaluation metrics and comparison with traditional attributions methods we used the quantus library
For other methods that don't exist in quantus library refer to this file
Add implementations on other architectures (ResNet18, ResNet50, ConvNext, ...) and datasets (MiniImageNet)
Licensed under Apache 2.0 License.
License will be released upon paper review completion