dgl.sparse.SparseMatrix.int
- SparseMatrix.int()[source]
将矩阵值转换为 int32 数据类型。如果矩阵已使用 int 数据类型,则返回原始矩阵。
- 返回值:
带有 int 值的矩阵
- 返回类型:
DiagMatrix
示例
>>> indices = torch.tensor([[1, 1, 2], [1, 2, 0]]) >>> A = dglsp.spmatrix(indices, shape=(3, 4)) >>> A.int() SparseMatrix(indices=tensor([[1, 1, 2], [1, 2, 0]]), values=tensor([1, 1, 1], dtype=torch.int32), shape=(3, 4), nnz=3)