from_scipy#
- iskra.sparse.from_scipy(x: coo_array | csr_array, device: device | str = 'cpu') SparseTensor[SOURCE]#
Converts SciPy sparse COO/CSR arrays into PyTorch sparse tensors.
- Parameters:
x (scipy.sparse.coo_array | scipy.sparse.csr_array) – SciPy sparse array to be converted.
device (torch.device | str) – Specifies the device on which to construct the tensor. Defaults to “cpu”.
- Raises:
ValueError – Throws an exception if the input array is neither COO nor CSR.
- Returns:
(
SparseTensor) – PyTorch tensor with the same data.