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

Method to_dense

python/dgl/sparse/sparse_matrix.py:203–216  ·  view source on GitHub ↗

Returns a copy in dense matrix format of the sparse matrix. Returns ------- torch.Tensor The copy in dense matrix format

(self)

Source from the content-addressed store, hash-verified

201 return self.c_sparse_matrix.csc()
202
203 def to_dense(self) -> torch.Tensor:
204 """Returns a copy in dense matrix format of the sparse matrix.
205
206 Returns
207 -------
208 torch.Tensor
209 The copy in dense matrix format
210 """
211 row, col = self.coo()
212 val = self.val
213 shape = self.shape + val.shape[1:]
214 mat = torch.zeros(shape, device=self.device, dtype=self.dtype)
215 mat[row, col] = val
216 return mat
217
218 def t(self):
219 """Alias of :meth:`transpose()`"""

Callers 15

asnumpyFunction · 0.80
asnumpyFunction · 0.80
test_graph_convFunction · 0.80
test_dense_cheb_convFunction · 0.80
sparse_matrix_to_denseFunction · 0.80
test_addsub_cooFunction · 0.80
test_addsub_csrFunction · 0.80
test_addsub_cscFunction · 0.80
test_addsub_diagFunction · 0.80
test_add_sparse_diagFunction · 0.80
test_sub_sparse_diagFunction · 0.80
test_spspmulFunction · 0.80

Calls 1

cooMethod · 0.95

Tested by 15

test_graph_convFunction · 0.64
test_dense_cheb_convFunction · 0.64
test_addsub_cooFunction · 0.64
test_addsub_csrFunction · 0.64
test_addsub_cscFunction · 0.64
test_addsub_diagFunction · 0.64
test_add_sparse_diagFunction · 0.64
test_sub_sparse_diagFunction · 0.64
test_spspmulFunction · 0.64
test_denseFunction · 0.64
test_bspmmFunction · 0.64
test_spspmmFunction · 0.64