torch_geometric.transforms.ToSparseTensor — pytorch_geometric documentation (original) (raw)

class ToSparseTensor(attr: Optional[str] = 'edge_weight', remove_edge_index: bool = True, fill_cache: bool = True, layout: Optional[int] = None)[source]

Bases: BaseTransform

Converts the edge_index attributes of a homogeneous or heterogeneous data object into a transposed torch_sparse.SparseTensor or PyTorch torch.sparse.Tensor object with key adj_t(functional name: to_sparse_tensor).

Note

In case of composing multiple transforms, it is best to convert thedata object via ToSparseTensor as late as possible, since there exist some transforms that are only able to operate ondata.edge_index for now.

Parameters: