dgl.sparse.SparseMatrix.long
- SparseMatrix.long()[source]
将矩阵值转换为 long 数据类型。如果矩阵已经使用 long 数据类型,则返回原始矩阵。
- 返回值:
具有 long 值的矩阵
- 返回类型:
DiagMatrix
示例
>>> 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)