easygraph.datapipe.common module#

easygraph.datapipe.common.compose_pipes(*pipes: Callable) Callable[source]#

Compose datapipe functions.

Parameters:

pipes (Callable) – Datapipe functions to compose.

easygraph.datapipe.common.to_bool_tensor(X: List | ndarray | Tensor) BoolTensor[source]#

Convert List, numpy.ndarray, torch.Tensor to torch.BoolTensor.

Parameters:

X (Union[List, np.ndarray, torch.Tensor]) – Input.

Examples

>>> import easygraph.datapipe as dd
>>> X = [[0.1, 0.2, 0.5],
         [0.5, 0.2, 0.3],
         [0.3, 0.2, 0]]
>>> dd.to_bool_tensor(X)
tensor([[ True,  True,  True],
        [ True,  True,  True],
        [ True,  True, False]])
easygraph.datapipe.common.to_long_tensor(X: List | ndarray | Tensor) LongTensor[source]#

Convert List, numpy.ndarray, torch.Tensor to torch.LongTensor.

Parameters:

X (Union[List, np.ndarray, torch.Tensor]) – Input.

Examples

>>> import easygraph.datapipe as dd
>>> X = [[1, 2, 5],
         [5, 2, 3],
         [3, 2, 0]]
>>> dd.to_long_tensor(X)
tensor([[1, 2, 5],
        [5, 2, 3],
        [3, 2, 0]])
easygraph.datapipe.common.to_tensor(X: list | ndarray | Tensor | csr_matrix) Tensor[source]#

Convert List, numpy.ndarray, scipy.sparse.csr_matrix to torch.Tensor.

Parameters:

X (Union[List, np.ndarray, torch.Tensor, scipy.sparse.csr_matrix]) – Input.

Examples

>>> import easygraph.datapipe as dd
>>> X = [[0.1, 0.2, 0.5],
         [0.5, 0.2, 0.3],
         [0.3, 0.2, 0]]
>>> dd.to_tensor(X)
tensor([[0.1000, 0.2000, 0.5000],
        [0.5000, 0.2000, 0.3000],
        [0.3000, 0.2000, 0.0000]])