Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem using GNNExplainer #429

Open
gonzalo-menendez opened this issue Mar 22, 2023 · 4 comments
Open

Problem using GNNExplainer #429

gonzalo-menendez opened this issue Mar 22, 2023 · 4 comments

Comments

@gonzalo-menendez
Copy link

Hey! I'm trying to use GNNExplainer to analyze my models, and i'm having some trouble.

First of all, my goal is to use it to evaluate a model built with ECCConv layers considering edge features. Looking at the implementation of GNNExplainer I don't think this is implemented. I was hoping you could give me a recommendation on whether it'd be best to try to modify the gnnexplainer class or if there's a simpler alternative.

In the meantime, I'm running a test using a model with GeneralConv gnn layers. For a sample graph, I'm getting the following masks:

a_mask:
(<tf.Variable 'Variable:0' shape=(28,) dtype=float32, numpy=
array([-0.6655016 , 0.5842006 , 0.39379573, 0.49623412, -0.45535487,
-0.02696309, -0.7784747 , 0.6405284 , -0.37123427, -0.23119783,
-0.38310692, 0.58059317, -0.12932119, -0.05058992, -0.05116389,
-0.23186898, 0.36419895, 0.7467144 , 0.7389943 , -0.55472755,
-0.6831169 , -1.7477793 , 1.0679742 , 0.6336443 , -0.02838329,
0.5035012 , 0.8304491 , -0.6139717 ], dtype=float32)>

x_mask:
<tf.Variable 'Variable:0' shape=(1, 6) dtype=float32, numpy=
array([[-0.2585382 , -0.01985877, -0.13091046, -0.15649146, -0.1051973 ,
-0.01794788]], dtype=float32)>)

What exactly does it mean for values to be negative? I would assume it means they are less important, but does this mean that ll my node features and most of my edges are getting ignored when scoring?

Also, when calling the plot_subgraph function the edges seem to be misplaced, not sure how to fix this.
image

Thanks!

@danielegrattarola
Copy link
Owner

I'm not 100% sure that GNNExplainer can work with the MessagePassing backend that GeneralConv uses.
In fact, I would expect it to crash because there should be no gradient flow between the output and the adjacency matrix.

Do you get more sensible results if you use a GCN backbone?

@gonzalo-menendez
Copy link
Author

I tried using GCNConv and I still get similar all-negative results. Either way, I need to make use of edge features, do you think it should work for ECCConv that allows for edge features?

@danielegrattarola
Copy link
Owner

ECCConv behaves like a MessagePassing layer underneath so no, I don't expect it to work.
Sorry but GNNExplainer was an external contribution and I haven't worked much with it, so your best bet is to play with it and see if you eventually get reasonable results.

@gonzalo-menendez
Copy link
Author

I see. Well, thanks anyways!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants