-
Hi, I am trying to make a prediction with GNN and obtain gradient w.r.t a node's feature, just like we can do with PyTorch: But when I want to do it with pytorch geometric, I failed. Here is the example code: It raises an error says: "RuntimeError: One of the differentiated Tensors appears to not have been used in the graph. Set allow_unused=True if this is the desired behavior." Here is the GNN I used: Any help is appreciated, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Solved, when computing gradient, I guess data.x is as a whole node in the computation graph. |
Beta Was this translation helpful? Give feedback.
Solved, when computing gradient, I guess data.x is as a whole node in the computation graph.
I take size_grad = grad(diff, x)[0], and then take the corresponding index from the gradient tensor, and it works now.