This repo contains PyTorch implementation of the paper: SAME: Uncovering GNN Black Box with Structure-aware Shapley-based Multipiece Explanations
in 2023 NeurIPS.
The recommended Python version is 3.8 or 3.9. (SAME is tested under Python 3.8, Pytorch 1.12.1 and PyG 2.1.0)
conda create -n same python==3.8
Then, please follow the Pytorch Guidelines to install Pytorch and INSTALL PYG to install PyG. After that, install other packages using:
pip install -r requirements.txt
For the datasets used in our paper, please download them manually and move them into the folder datasets/
. The file name is case sensitive and please make sure that all of the file names are in lowercase. For more information about the datasets, please refer to dataset.py
.
Here we provide the link to download them. (SAME_datasets
contains both raw and processed data. If you want raw data only, please kindly click SAME_raw_datasets
)
SAME_datasets FILE_ID=1VXfb6hnKZ3nBsKMJPqvjI4Nz0ikk8skT
SAME_raw_datasets FILE_ID=1KqSHf6Xz_PXKNA6KwXucye1H18hKIMJ6
[Easy for Terminal] You can download the dataset using the following bash. Remember to replace FILE_ID
with that shown above.
# install gdown to down file from google drive
pip install gdown
# download file using FILE_ID
gdown https://drive.google.com/uc?id=FILE_ID
Please use the following bash
script to train the GNN models. Our code contains the implementation of GCN
, GAT
and GIN
. The trained checkpoints of these models will be saved in checkpoints/
.
python train_gnns.py models='gcn' datasets='mutag'
- Train GNNs before explaining.
- The
models
argument can be chosen fromGCN
,GAT
orGIN
. And you can create your own GNN model ingetNets.py
. - For other datasets and GNNs, please create the corresponding files in
config
.
- The
python train_gnns.py datasets='mutag' models='gin'
- One-Click run: use the following script to run the experiments thoroughly. The script will automatically run the experiments in the sparsity
$[0.5,0.6,0.7,0.8]$ .
bash main.sh
- Otherwise, you can run one explainer to explain a trained GNN model
- You can run other baseline methods by setting
explainer
asgnn_explainer
,pgexplainer
,gnn_lrp
,grad_cam
,subgraphX
,gstarx
,orphicx
, andgraphsvx
- You can run other baseline methods by setting
explainer=same
dataset_name=bbbp
sparsity=0.8
model_name=gcn
bash run_one_model.sh $explainer $dataset_name $sparsity $model_name
Some baseline methods of our code are adapted from the following repositories.
https://github.com/ShichangZh/GStarX
https://github.com/divelab/DIG/tree/main/dig/xgraph
If you have any questions, please feel free contact us: [email protected] and rihanhuang.work@gmail or open an issue.