关于理解节点和边索引的说明

扎眼的阳光 pytorch 191

原文标题Clarification on understanding the node and edge index

通过访问数据对象的属性,我怎么知道哪个节点特征属于哪个节点?如果我理解正确,data.x 包含节点特征。通过在下面运行 for 循环,我可以访问这些特征,但我怎么知道它是否属于以节点 0 或节点 9 为例?

from torch_geometric.data import Data
edge_index = torch.tensor([[0, 1, 1, 2, 1, 9],
                           [1, 0, 2, 1, 8, 1]
                           ], dtype=torch.long)
x = torch.tensor([[-5,7], [0,5], [0,9], [10,9]], dtype=torch.float)
​
data = Data(x=x, edge_index=edge_index)
​
for item in range(0, data.x.shape[0]):
    print(item, data.x[item], data.edge_index.t()[item])

原文链接:https://stackoverflow.com//questions/71441535/clarification-on-understanding-the-node-and-edge-index

回复

我来回复
  • lpt的头像
    lpt 评论

    这个例子有外行理解pyG数据格式的方式:

    https://medium.com/stanford-cs224w/fraud-detection-with-gat-edac49bda1a0
    
    2年前 0条评论