abracudabra.conversion.ctensor#
Convert to torch tensor.
Functions#
|
Convert an array, series, or dataframe to a torch tensor. |
|
Convert an array, series, or dataframe to a torch tensor. |
Module Contents#
- abracudabra.conversion.ctensor._to_tensor(sequence: abracudabra.annotations.Array | abracudabra.annotations.Series | abracudabra.annotations.DataFrame | torch.Tensor, /, *, strict: bool = False) torch.Tensor [source]#
Convert an array, series, or dataframe to a torch tensor.
The device of the tensor is determined by the device of the input.
- abracudabra.conversion.ctensor.to_tensor(sequence: abracudabra.annotations.Array | abracudabra.annotations.Series | torch.Tensor, /, device: abracudabra.device.base.Device | str | None = None, *, strict: bool = False) torch.Tensor [source]#
Convert an array, series, or dataframe to a torch tensor.
- Parameters:
sequence – The sequence to convert.
device – The device to convert the sequence to. If None, the sequence stays on the same device.
strict – Whether to raise an error if the sequence is not a valid type. A numpy/cupy array, pandas/cudf series or dataframe, or torch tensor are valid types. If False, the sequence is converted to a torch tensor if possible, but it might raise an error if the conversion is not possible.
- Returns:
A torch tensor.