官方文档对方法进行以下描述:
"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
我想知道将稠密邻接矩阵转换为稀疏邻接矩阵的意义是什么?
因为运算复杂度。如果用dense matrix做gcn layer的multiplicaition, 复杂度远远高于 两个sparse matrix做multiplication。因为是sparse,很多地方都避免了运算,但dense matrix仍需要遍历所有位置。
这个问题提的很好