Pytorch 我如何理解torch_geometric的函数,它被称为稠密_to_稀疏()?;
官方文件对该功能的描述如下: “将密集邻接矩阵转换为定义的稀疏邻接矩阵 通过边索引和边属性。” 所以我想知道把密集邻接矩阵转换成稀疏邻接矩阵的意义是什么Pytorch 我如何理解torch_geometric的函数,它被称为稠密_to_稀疏()?;,pytorch,torch,Pytorch,Torch,官方文件对该功能的描述如下: “将密集邻接矩阵转换为定义的稀疏邻接矩阵 通过边索引和边属性。” 所以我想知道把密集邻接矩阵转换成稀疏邻接矩阵的意义是什么 assert tensor.dim() == 2 index = tensor.nonzero().t().contiguous() value = tensor[index[0], index[1]] return index, value
assert tensor.dim() == 2
index = tensor.nonzero().t().contiguous()
value = tensor[index[0], index[1]]
return index, value