question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`GNNExplainer` for link prediction

See original GitHub issue

❓ Questions & Help

Hi @rusty1s,

I wrote a GNN model by pytorch geometric to do the link prediction which refers to this example. The forward part of the model is showed below. I tried to use GNNExplainer to explain my model but got an error forward() got an unexpected keyword argument 'edge_index'. Since my forward doesn’t directly use edge_index, this might cause the issue. Is it possible that I can have an example to use GNNExplainer for link prediction? Or some instructions to modify the GNNExplainer for my model? Thank you!

    def forward(self, x, adjs, link, n_id):
        for i, (edge_index, _, size) in enumerate(adjs):
            x_target = x[:size[1]]  # Target nodes are always placed first.
            x = self.convs[i]((x, x_target), edge_index)
            if i != self.num_layers - 1:
                x = F.relu(x)
                x = F.dropout(x, p=self.dropout_p, training=self.training)

        x = x[[list(np.where(n_id.numpy()==i.numpy())[0])[0] for i in link[:,0]]] * x[[list(np.where(n_id.numpy()==i.numpy())[0])[0] for i in link[:,1]]]
        x = torch.sigmoid(self.lin(x)).squeeze(1)

        return x

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

8reactions
Alec-Stashevskycommented, Mar 24, 2022

I would also like to put in a vote for adding link-prediction functionality to the GNNExplainer class!

5reactions
rusty1scommented, Mar 24, 2022

Noted 😃 Let’s see what we can do!

Read more comments on GitHub >

github_iconTop Results From Across the Web

`GNNExplainer` for link prediction · Issue #1728 - GitHub
I wrote a GNN model by pytorch geometric to do the link prediction which refers to this example. The forward part of the...
Read more >
GNN-Explainer - SNAP: Stanford
GNN-Explainer is a general tool for explaining predictions made by graph ... Node classification; Graph classification; Link prediction.
Read more >
GNNExplainer: Generating Explanations ... - Papers With Code
We formulate GNNExplainer as an optimization task that maximizes the mutual information between a GNN's prediction and distribution of possible subgraph ...
Read more >
SEAL Link Prediction, Explained - Towards Data Science
Link prediction is a really hot topic of research in the graph field. For example, given a social network below with different nodes...
Read more >
GNNExplainer: Generating Explanations for Graph Neural ...
The approach is model-agnostic and can explain predictions of any GNN on any machine learning task for graphs, including node classification, link prediction, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found