Skip to content

Framework for explaining Keras/Tensorflow Graph Neural Network decisions.

License

Notifications You must be signed in to change notification settings

robinruff/GNNExplainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The code in this repository is now integrated into KGCNN repository.

GNNExplainer

This repository provides a way to explain Keras/Tensorflow Graph Neural Network decisions. The basic idea behind the generation method for explanations is heavily inspired by the paper "GNNExplainer: Generating Explanations for Graph Neural Networks" by Ying et al., although it differs in some aspects.

Structure of this Repository

.
├── LICENSE                           # License file
├── README.md                         # This README
├── abschlussbericht.ipynb            # Final report on the project
├── examples                          
│   ├── cora                          
│   │   ├── data                      # Cora dataset
│   │   ├── dataloader.py             # Data loading utility
│   │   └── example_notebook.ipynb    # Example for CORA 
│   └── mutagenicity                  
│       ├── data                      # Mutagenicity dataset
│       ├── dataloader.py             # Data loading utility
│       ├── example_notebook.ipynb    # Mask on input
│       ├── example_notebook2.ipynb   # Mask on GNN operation
│       └── example_notebook3.ipynb   # Multi-Instance explanations 
├── gnnx                              # gnnx-Package
│   ├── __init__.py
│   └── gnnx.py                       # Core implemenation
├── pyproject.toml
└── setup.py

Installation of the gnnx package

pip install -e .

Example Workflow

# Configuration
compile_options = {'loss': 'binary_crossentropy'}
fit_options = {'epochs': 100}
config = {
	'edge_mask_loss_weight': 0.01,    # λ_M
	'edge_mask_norm_ord': 1,          # p_M
	'feature_mask_loss_weight': 0.01, # λ_F
	'feature_mask_norm_ord': 1,       # p_F
	'node_mask_loss_weight': 0,       # λ_N
	'node_mask_norm_ord': 1}          # p_N
# Setup. Instantiating the GNNExplainer
explainer = gnnx.GNNExplainer(
    gnn, # Implements gnnx.GNNInterface
	compile_options=compile_options,
	fit_options=fit_options,
	gnnexplaineroptimizer_options=config)
# Explaining Decisions
explainer.explain(input_instance) 
explanation = explainer.get_explanation() 
explainer.present_explanation(explanation) 

For more examples look inside the examples directory.

Class Diagram for gnnx package

Class diagram

About

Framework for explaining Keras/Tensorflow Graph Neural Network decisions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages