ksuit.data.preprocessors.utils

Functions

to_tensor(data)

Helper function to convert input data to a PyTorch tensor if it is not already one.

Module Contents

ksuit.data.preprocessors.utils.to_tensor(data)

Helper function to convert input data to a PyTorch tensor if it is not already one.

Parameters:

data (ksuit.data.preprocessors.types.ScalarOrSequence) – The input data to convert. Can be a sequence of floats, a torch.Tensor, or None.

Return type:

torch.Tensor

Returns: The input data as a torch.Tensor if it was a sequence, the original tensor if it was already a torch.Tensor, or None if the input was None. :raises TypeError: If the input data is of an unsupported type.