dgl
dgl copied to clipboard
A question about dgl.nn.PyTorch.EGTLayer
I have a question about dgl.nn.PyTorch.EGTLayer. I don't know how to define the mask parameter in the forward function. According to the official documentation, I define the mask variable with the valid position set to 0 and the invalid position set to -inf. But my model weight always changes to Nan every time I execute the code. But that doesn't happen when I don't use the mask variable. So now I don't know how to define the mask variable. Can you give an example of using the mask variable? Thank you!
The number of graph nodes I use is different, so I'll add nodes to each graph up to the maximum number of nodes. At the same time, the corresponding position of the mask variable is -inf
This issue has been automatically marked as stale due to lack of activity. It will be closed if no further activity occurs. Thank you
I think the Nans come from padding. As an example, for a batch of a 2-node graph and a 4-node graph, the mask should be
tensor([[[0., 0., -inf, -inf],
[0., 0., -inf, -inf],
[0., 0., -inf, -inf],
[0., 0., -inf, -inf]],
[[0., 0., 0., 0.],
[0., 0., 0., 0.],
[0., 0., 0., 0.],
[0., 0., 0., 0.]]])
instead of
tensor([[[0., 0., -inf, -inf],
[0., 0., -inf, -inf],
[-inf, -inf, -inf, -inf],
[-inf, -inf, -inf, -inf]],
[[0., 0., 0., 0.],
[0., 0., 0., 0.],
[0., 0., 0., 0.],
[0., 0., 0., 0.]]])
Rows full of -inf in the second example will lead to Nans because of a softmax operation with all input values as -inf.
This issue has been automatically marked as stale due to lack of activity. It will be closed if no further activity occurs. Thank you