Conversion: numpy#
This module contains safe functions for numpy and pytorch interconversion.
- tad_mctc.convert.numpy.numpy_to_tensor(x, device=None, dtype=None)[source]#
Convert a numpy array to a PyTorch tensor.
- Parameters:
x (NDArray[Any]) – Array to convert.
device (
torch.device| None, optional) – Device to store the tensor on. Defaults to None.dtype (
torch.dtype| None, optional) – Data type of the tensor. Defaults to None.
- Returns:
Converted PyTorch tensor.
- Return type:
Tensor