Edge Weight Hetero Graph

Hi there!

I want to use edge weights in my heterogeneous graph and I saw a great post, which explains on how to add edge weights ([Mask edges for RGCN]). I also want to use Integrated Gradients to get “edge explainability”, however it is not possible to get the the sum of gradients of outputs with respect to the inputs. Does anyone know what I am missing ?

Thanks in advance !

Hi @Julie,

  1. In your script, the conv operations are performed before you call requires_grad_(True). So the operations are not recorded for autograd. Please set requires_grad_(True) when you initialize mask1 and mask2.

  2. The computation for node feature of the first game node is not related to mask1 because mask1 is applied on edges between user nodes. You can call torch.autograd.grad with flag allow_unused=True to avoid the error and get grad values as None. Besides, grads = torch.autograd.grad(torch.unbind(out['game'][5]), mask2) could be a better case to show, because the output of the node game(5) is influenced by both the last two edges in edges2.

1 Like

Hi, very helpful ! It works, thank you very much :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.