skylon. 2021-05-19 21:21 采纳率: 0%
浏览 1094

怎么理解torch_geometric中的dense_to_sparse()方法?

官方文档对方法进行以下描述:

"Converts a dense adjacency matrix to a sparse adjacency matrix defined
by edge indices and edge attributes."
assert tensor.dim() == 2
index = tensor.nonzero().t().contiguous()
value = tensor[index[0], index[1]]
return index, value

我想知道将稠密邻接矩阵转换为稀疏邻接矩阵的意义是什么?

 

  • 写回答

2条回答 默认 最新

  • weixin_39198171 2021-12-23 17:14
    关注

    因为运算复杂度。如果用dense matrix做gcn layer的multiplicaition, 复杂度远远高于 两个sparse matrix做multiplication。因为是sparse,很多地方都避免了运算,但dense matrix仍需要遍历所有位置。

    评论

报告相同问题?