What is the difference edge_weight and edge_attr in Pytorch Geometric
Asked Answered
H

2

7

I want to handle weighted undirected graphs in Pytorch Geometric. The node features are 50 dimensional. I found that this can be handled by the x attribute of the torch_geometric.data.data class. The weights of the edges are scalar values. We found out that edge_attr and edge_weight are the attributes to handle edges.

I think I should probably use edge_weight, is this correct?

Also, what is the difference between edge_attr and edge_weight?

I'm not very good at English, so I apologize for that. I hope I can get a good answer.

Thank you.

Heraclitus answered 14/10, 2021 at 6:18 Comment(1)
This answer might be useful ai.stackexchange.com/questions/16805/…Aha
P
9

The difference between edge_weight and edge_attr is that edge_weight is always one-dimensional (one value per edge) and that edge_attribute can be multi-dimensional. You can check the cheatsheet for the support of the models.

Progesterone answered 3/1, 2022 at 16:11 Comment(2)
No, the edge attribute contains features for the edges which can be used to calculate the message in a learnable way. The edge weights just scale the messages.Wexford
@Wexford doesn't that implies also that edge weights have to be one-dimensional? I tested a forward pass of a GATConv layer and it works also if you pass an edge_weight tensor which has multiple dimensional so it is still not clear and the documentation does not help in any wayBaldridge
L
4

The difference between edge_weight and edge_attr is that edge_weight is the non-binary representation of the edge connecting two nodes, without edge_weight the edge connecting two nodes either exists or it doesn't(0 or 1) but with the weight the edge connecting the nodes can have arbitrary value.

Whereas edge_attr means the features of the edge connecting any two nodes. These feature can be multidimensional.

Lucilucia answered 3/4, 2022 at 15:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.