YouTip LogoYouTip

Pytorch Torch Sparse_Csc_Tensor

# PyTorch torch.sparse_csc_tensor Function * * Pytorch torch Reference Manual](#) `torch.sparse_csc_tensor` is a function in PyTorch used to construct sparse CSC (Compressed Sparse Column) tensors. ### Function Definition torch.sparse_csc_tensor(ccol_indices, row_indices, values, size=None, dtype=None, device=None, requires_grad=False) * * * ## Usage Example ## Example import torch # Create sparse CSC tensor # Column pointers ccol_indices = torch.tensor([0,1,2,3]) # Row indices row_indices = torch.tensor([0,1,2,0]) # Values values = torch.tensor([1.0,2.0,3.0,4.0]) # Tensor size size =(3,3) # Construct sparse CSC tensor x = torch.sparse_csc_tensor(ccol_indices, row_indices, values, size) print(x) print("Dense tensor:") print(x.to_dense()) * * Pytorch torch Reference Manual](#)
← Pytorch Torch SplitPytorch Torch Sort β†’