Official implementation of EiX-GNN : Concept-level eigencentrality explainer for graph neural networks (EiXGNN) , torch-geometric implementation 📚
Go to file
araison 9b645ad8d8 Update 2024-04-28 16:00:08 +02:00
docs Updating 2024-04-28 15:56:13 +02:00
eixgnn Update README.md 2023-03-06 11:47:32 +01:00
test Updating 2024-04-28 15:56:13 +02:00
.coveragerc Updating 2024-04-28 15:56:13 +02:00
.gitignore Updating 2024-04-28 15:56:13 +02:00
AUTHORS.md Updating 2024-04-28 15:56:13 +02:00
CHANGELOG.md Updating 2024-04-28 15:56:13 +02:00
CONTRIBUTING.md Updating 2024-04-28 15:56:13 +02:00
LICENCE Updating 2024-04-28 15:56:13 +02:00
Makefile Updating 2024-04-28 15:56:13 +02:00
README.md Update 2024-04-28 16:00:08 +02:00
__init__.py Github release 2023-03-06 11:35:30 +01:00
setup.cfg Updating 2024-04-28 15:56:13 +02:00
setup.py Github release 2023-03-06 11:35:30 +01:00

README.md

EiX-GNN

Official implementation of EiXGNN algorithm. For further informations, see EiX-GNN: Concept-level eigencentrality explainer for graph neural networks, paper.

Run an example

from torch_geometric.datasets import TUDataset

dataset = TUDataset(root="/tmp/ENZYMES", name="ENZYMES")
data = dataset[0]

import torch.nn.functional as F
from torch_geometric.nn import GCNConv, global_mean_pool
from eixgnn.eixgnn import EiXGNN

class GCN(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = GCNConv(dataset.num_node_features, 20)
        self.conv2 = GCNConv(20, dataset.num_classes)

    def forward(self, data):
        x, edge_index, batch = data.x, data.edge_index, data.batch
        x = self.conv1(x, edge_index)
        x = F.relu(x)
        x = global_mean_pool(x, batch)
        x = F.softmax(x, dim=1)
        return x

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = GCN().to(device)
model.eval()
data = dataset[0].to(device)
explainer = EiXGNN()
explained = explainer.forward(model, data.x, data.edge_index)