How can I get two representations of a node from different relations

this is my graph
image
the cell node has two source


Without destroying backward

I feel your setup is correct. What is the error you got? Also, if you could give us a small runnable script that reproduce the problem, that’ll be very helpful.

Thank you for your reply.
I want to get a representation of cell nodes from mod1 and a representation from mod2
but the HeteroGraphConv aggregate them by ‘stack’
I use a list to store two representation and return
but I got the error

RuntimeError: Trying to backward through the graph a second time (or directly access saved tensors after they have already been freed). Saved intermediate values of the graph are freed when you call .backward() or autograd.grad(). Specify retain_graph=True if you need to backward through the graph a second time or if you need to access saved tensors after calling backward.

then I add retain_graph=True loss.backward(retain_graph=True)
it not work

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