python - Pytorch 几何稀疏邻接矩阵到边索引张量

标签 python graph pytorch adjacency-matrix pytorch-geometric

我的数据对象有 data.adj_t 参数,给我稀疏邻接矩阵。如何从中获取大小为 [2, num_edges]edge_index 张量?

最佳答案

正如您在 docs 中看到的那样:

Since this feature is still experimental, some operations, e.g., graph pooling methods, may still require you to input the edge_index format. You can convert adj_t back to (edge_index, edge_attr) via:

row, col, edge_attr = adj_t.t().coo()
edge_index = torch.stack([row, col], dim=0)

关于python - Pytorch 几何稀疏邻接矩阵到边索引张量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69091074/

相关文章:

r - r中的人口金字塔密度图

python - pytorch如何在克隆张量后计算梯度

python - 多线程/多处理以避免响应超时

python - 仅在代码的某些部分记录打印两次

python - 每个 python 包都需要 __init__.py 吗? [自 python 3.3+ 以来的新功能]

ios - Coreplot 注释绘制在轴上

python - 在 Python 中将字符串拆分为列表

database - Cypher 访问空间分隔的关系属性 neo4j

r - 从句子转换器创建对象时 GPU 内存泄漏

python - 当 x , y 未给出时如何解释 torch.where() 输出?