Coder Social home page Coder Social logo

jordan7186 / gatt Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 1.38 MB

Source code for the GAtt method in "Revisiting Attention Weights as Interpretations of Message-Passing Neural Networks".

Home Page: https://arxiv.org/abs/2406.04612

License: MIT License

Dockerfile 0.03% Jupyter Notebook 93.04% Python 6.94%
attention attention-mechanism attribution-methods graph-attention-model graph-attention-networks explainable-ai python xai

gatt's Introduction

Source code for GAtt

This repository is the official implementation of Revisiting Attention Weights as Interpretations of Message-Passing Neural Networks. In the paper, we show that GAtt provides a better way to calculate edge attribution scores from attention weights in attention-based GNNs!

We have a Dockerfile for running locally:

Just clone the repo, and build the docker image by:

docker build <directory_to_cloned_repo> --tags <your:tags>

If you don't want Docker...

The code is tested in...

  • Python 3.10.13
  • Pytorch 2.0.1+cu117
  • Pytorch Geometric 2.3.1

which should be enough to run the demos.

Provided in this repo are...

  1. Source code for GAtt
  2. Demos
  • Demo on the Cora dataset on how to use the get_gatt and the get_gatt_batch function
  • Demo on the BAShapes (generated from torch_geometric.datasets.ExplainerDataset): Visualizations of GAtt and comparison to AvgAtt
  • Demo on the Infection dataset (generated from the code in the original authors' repo): Visualizations of GAtt and comparison to AvgAtt

Results for Infection dataset

This is one of the results in the demo notebooks:

Figure (left to right)

  • Ground truth explanation (blue edges) for the target node (orange node)
  • Edge attribution from GAtt
  • Edge attribution from AvgAtt (averaging over the layers)

The figures show that the edge attribution scores in GAtt is more aligned with the ground truth explanation edges compared to just averaging over the GAT layers.

gatt's People

Contributors

jordan7186 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

wozaimoyu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.