tensor

Utility functions for PyTorch tensors.

Functions

torch_to

Try to recursively move the data to the specified args/kwargs.

torch_detach

Try to recursively detach the data from the computation graph.

torch_to_numpy

Convert torch tensors to numpy arrays.

numpy_to_torch

Convert numpy arrays to torch tensors.

numpy_to_torch(np_outputs)

Convert numpy arrays to torch tensors.

Parameters:

np_outputs (List[ndarray]) –

Return type:

List[Tensor]

torch_detach(data)

Try to recursively detach the data from the computation graph.

torch_to(data, *args, **kwargs)

Try to recursively move the data to the specified args/kwargs.

torch_to_numpy(inputs)

Convert torch tensors to numpy arrays.

Parameters:

inputs (List[Tensor]) –

Return type:

List[ndarray]