【问题标题】:Pytorch geometric: how to explain the input in the below code-snippet?Pytorch 几何:如何解释以下代码片段中的输入?
【发布时间】:2021-09-05 02:03:39
【问题描述】:

我正在https://pytorch-geometric.readthedocs.io/en/latest/notes/introduction.html阅读 PyTorch 几何文档

在这个页面上有一个代码sn-p:

import torch
from torch_geometric.data import Data

edge_index = torch.tensor([[0, 1, 1, 2],
                           [1, 0, 2, 1]], dtype=torch.long)
x = torch.tensor([[-1], [0], [1]], dtype=torch.float)

data = Data(x=x, edge_index=edge_index)

上面代码sn-p最后一行的输出是:

Data(edge_index=[2, 4], x=[3, 1])

edge_index 2 和 4 怎么样?如果我理解正确,则定义了四个边,索引从 0 开始。这个假设是错误的吗?还有,x =[3, 1]是什么意思?

Data 是一个类,所以我不希望它返回任何东西。类定义在这里:https://pytorch-geometric.readthedocs.io/en/latest/modules/data.html。我阅读了文档。 x 应该是节点特征矩阵,edge_index 应该是图连接。但我不明白我在 jupyter notebook 中交叉检查的控制台输出。

【问题讨论】:

    标签: python machine-learning pytorch data-science pytorch-geometric


    【解决方案1】:

    好的,我想我已经了解了输出Data(edge_index=[2, 4], x=[3, 1])。这里 [2,4] 是 edge_index 的维度,[3,1] 是 x 的维度。但是,如果我错了,请任何人纠正我。

    【讨论】:

    • 这正是对输出的正确解释。您有 4 条边(或两条无向边),对于 3 个节点中的每一个,您都有一个一维特征,请参阅 here
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-03
    • 2015-06-23
    • 2018-06-11
    • 2018-05-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多