ksuit.data.preprocessors.preprocessor¶
Classes¶
Base class for all data preprocessors. |
Module Contents¶
- class ksuit.data.preprocessors.preprocessor.PreProcessor(normalization_key)¶
Base class for all data preprocessors. .. rubric:: Example
>>> class MyPreProcessor(PreProcessor): >>> def __init__(self, normalization_key: "image"): >>> super().__init__(normalization_key=normalization_key) >>> def __call__(self, x): >>> # Example processing: normalize to [0, 1] >>> return x / 255.0 >>> def denormalize(self, x): >>> # Example denormalization: scale back to [0, 255] >>> return x * 255.0
- Parameters:
normalization_key (str) – key to identify on which getitem_ in the dataset/tensor the preprocessor is applied.
- Raises:
TypeError – If normalization_key is not a string.
- normalization_key¶
- abstractmethod denormalize(x)¶
Denormalizes the input data. This method should be overridden by subclasses if denormalization is supported. If denormalization is not supported, it raises NotImplementedError or decide to implement the identity function.
- Parameters:
x (torch.Tensor) – The input tensor to denormalize.
- Return type:
torch.Tensor