项目文件夹

文件
YanJun-Zhao ec4271bf87 [Example] Refactor GNNExplainer Example (#4560)
* debug

* debug

* readme

* fix readme

* fix readme

* Update

* Update

* update

* fix bug of syn2

Co-authored-by: Ubuntu <ubuntu@ip-172-31-9-26.ap-northeast-1.compute.internal>
Co-authored-by: Mufei Li <mufeili1996@gmail.com>
2022-09-21 13:34:39 +08:00

2.1 KiB

DGL Implementation of GNNExplainer

This is a DGL example for GNNExplainer: Generating Explanations for Graph Neural Networks. For the authors' original implementation, see here.

Contributors:

Datasets

Four built-in synthetic datasets are used in this example.

Usage

First, train a GNN model on a dataset.

python train_main.py  --dataset $DATASET

Valid options for $DATASET: BAShape, BACommunity, TreeCycle, TreeGrid

The trained model weights will be saved to model_{dataset}.pth

Second, install GNNLens2 with

pip install -U flask-cors
pip install Flask==2.0.3
pip install gnnlens

Third, explain the trained model with the same dataset

python explain_main.py --dataset $DATASET

Finally, launch GNNLens2 to visualize the explanations

gnnlens --logdir gnn_subgraph

By entering localhost:7777 in your web browser address bar, you can see the GNNLens2 interface. 7777 is the default port GNNLens2 uses. You can specify an alternative one by adding --port xxxx after the command line and change the address in the web browser accordingly.

A sample visualization is available below. For more details of using GNNLens2, check its tutorials.


Figure: Explanation for node 41 of BAShape