dgl.sparse.SparseMatrix.long
- SparseMatrix.long()[source]
将矩阵值转换为长整型数据类型。如果矩阵已经使用长整型数据类型,将返回原始矩阵。
- Returns:
具有长值的矩阵
- Return type:
对角矩阵
示例
>>> indices = torch.tensor([[1, 1, 2], [1, 2, 0]]) >>> A = dglsp.spmatrix(indices, shape=(3, 4)) >>> A.long() SparseMatrix(indices=tensor([[1, 1, 2], [1, 2, 0]]), values=tensor([1, 1, 1]), shape=(3, 4), nnz=3)