torch_sparse_coo_tensor | R Documentation |
Sparse_coo_tensor
torch_sparse_coo_tensor(
indices,
values,
size = NULL,
dtype = NULL,
device = NULL,
requires_grad = FALSE
)
indices |
(array_like) Initial data for the tensor. Can be a list, tuple, NumPy |
values |
(array_like) Initial values for the tensor. Can be a list, tuple, NumPy |
size |
(list, tuple, or |
dtype |
( |
device |
( |
requires_grad |
(bool, optional) If autograd should record operations on the returned tensor. Default: |
Constructs a sparse tensors in COO(rdinate) format with non-zero elements at the given indices
with the given values
. A sparse tensor can be uncoalesced
, in that case, there are duplicate
coordinates in the indices, and the value at that index is the sum of all duplicate value entries:
torch_sparse
_.
if (torch_is_installed()) {
i = torch_tensor(matrix(c(1, 2, 2, 3, 1, 3), ncol = 3, byrow = TRUE), dtype=torch_int64())
v = torch_tensor(c(3, 4, 5), dtype=torch_float32())
torch_sparse_coo_tensor(i, v)
torch_sparse_coo_tensor(i, v, c(2, 4))
# create empty sparse tensors
S = torch_sparse_coo_tensor(
torch_empty(c(1, 0), dtype = torch_int64()),
torch_tensor(numeric(), dtype = torch_float32()),
c(1)
)
S = torch_sparse_coo_tensor(
torch_empty(c(1, 0), dtype = torch_int64()),
torch_empty(c(0, 2)),
c(1, 2)
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.