torch.Tensor.to_sparse_coo¶
- Tensor.to_sparse_coo()[source][source]¶
Convert a tensor to coordinate format.
Examples:
>>> dense = torch.randn(5, 5) >>> sparse = dense.to_sparse_coo() >>> sparse._nnz() 25
Convert a tensor to coordinate format.
Examples:
>>> dense = torch.randn(5, 5)
>>> sparse = dense.to_sparse_coo()
>>> sparse._nnz()
25