gwexpy.interop.torch_#
Interoperability with PyTorch tensors.
Functions
|
Create a TimeSeries from a PyTorch tensor. |
|
Convert a series to a PyTorch tensor. |
- gwexpy.interop.torch_.to_torch(series: TimeSeries | Any, device: str | torch.device | None = None, dtype: torch.dtype | None = None, requires_grad: bool = False, copy: bool = False) torch.Tensor#
Convert a series to a PyTorch tensor.
- Parameters:
series (TimeSeries or array-like) – Input data.
device (str or torch.device, optional) – Target device.
dtype (torch.dtype, optional) – Target dtype.
requires_grad (bool, optional) – Whether to track gradients.
copy (bool, optional) – If True, always copy data; otherwise share memory if possible.
- Returns:
The converted tensor.
- Return type:
torch.Tensor