MCPcopy
hub / github.com/dmlc/dgl / float

Method float

python/dgl/sparse/sparse_matrix.py:343–364  ·  view source on GitHub ↗

Converts the matrix values to float32 data type. If the matrix already uses float data type, the original matrix will be returned. Returns ------- SparseMatrix The matrix with float values Examples -------- >>> indices = torch.te

(self)

Source from the content-addressed store, hash-verified

341 return self.to(device="cpu")
342
343 def float(self):
344 """Converts the matrix values to float32 data type. If the matrix
345 already uses float data type, the original matrix will be returned.
346
347 Returns
348 -------
349 SparseMatrix
350 The matrix with float values
351
352 Examples
353 --------
354
355 >>> indices = torch.tensor([[1, 1, 2], [1, 2, 0]])
356 >>> val = torch.ones(len(row)).long()
357 >>> A = dglsp.spmatrix(indices, val, shape=(3, 4))
358 >>> A.float()
359 SparseMatrix(indices=tensor([[1, 1, 2],
360 [1, 2, 0]]),
361 values=tensor([1., 1., 1.]),
362 shape=(3, 4), nnz=3)
363 """
364 return self.to(dtype=torch.float)
365
366 def double(self):
367 """Converts the matrix values to double data type. If the matrix already

Callers 6

node_samplerMethod · 0.45
edge_samplerMethod · 0.45
processMethod · 0.45
to_floatFunction · 0.45
forwardMethod · 0.45
forwardMethod · 0.45

Calls 1

toMethod · 0.95

Tested by

no test coverage detected