How is edge attr is calculatedin PyG? #4019
-
If edge index is not just 1 but with weight, I can see that it is regarded as the importance of the neighbor nodes. But if there are several edge attributes information, how is it calculated for the embedding update? Will the edge attr be just concatenated with edge weight? Let's say edge weight is 0.7 for a node and there are 3 different normalized edge attr [speed = 0.6, price = 0.9, time = 0.2]. Then will the edge_index weight value will be like [0.7, 0.6, 0.9, 0.2]? Is it how PyG is doing? Could you give me some good examples? Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
PyG does not perform any magic here. There exists GNN operators than can either (1) not incorporate edge features at all, (2) one-dimensional edge weights, or (3) multi-dimensional edge features. How the edge features are treated inside each operator depends on the operator. Importantly, if you have both edge weights and features, you are responsible to perform the concatenation by yourself, e.g., For multi-dimensional edge features, most GNN operators that can incorporate those will usually just concatenate them to the source node features inside |
Beta Was this translation helpful? Give feedback.
PyG does not perform any magic here. There exists GNN operators than can either (1) not incorporate edge features at all, (2) one-dimensional edge weights, or (3) multi-dimensional edge features. How the edge features are treated inside each operator depends on the operator. Importantly, if you have both edge weights and features, you are responsible to perform the concatenation by yourself, e.g.,
edge_attr = torch.cat([edge_weight.view(-1, 1), edge_attr], dim=-1)
.For multi-dimensional edge features, most GNN operators that can incorporate those will usually just concatenate them to the source node features inside
message
.