dgl.sparse.SparseMatrix.float

SparseMatrix.float()[source]

Converts the matrix values to float32 data type. If the matrix already uses float data type, the original matrix will be returned.

Returns:

The matrix with float values

Return type:

SparseMatrix

Examples

>>> indices = torch.tensor([[1, 1, 2], [1, 2, 0]])
>>> val = torch.ones(len(row)).long()
>>> A = dglsp.spmatrix(indices, val, shape=(3, 4))
>>> A.float()
SparseMatrix(indices=tensor([[1, 1, 2],
                             [1, 2, 0]]),
             values=tensor([1., 1., 1.]),
             shape=(3, 4), nnz=3)