Skip to content

composite_transform

CompositeTransform

Bases: BaseTransform

Source code in lightning_boost/modules/preprocessing/composite_transform.py
class CompositeTransform(BaseTransform):
    def __init__(self, transforms: List[BaseTransform]) -> None:
        self.transforms = transforms

    def __call__(
        self, inputs: Dict[str, Any], targets: Dict[str, Any]
    ) -> Tuple[Dict[str, Any], Dict[str, Any]]:
        """
        Performs the given transforms in the specified order for inputs and targets.

        Args:
            inputs (Dict[str, Any]): Inputs.
            targets (Dict[str, Any]): Targets.

        Returns:
            Tuple[Dict[str, torch.Tensor], Dict[str, torch.Tensor]]: Inputs, targets (transformed).
        """

        for transform in self.transforms:
            inputs, targets = transform(inputs, targets)

        return inputs, targets

__call__(inputs, targets)

Performs the given transforms in the specified order for inputs and targets.

Parameters:

Name Type Description Default
inputs Dict[str, Any]

Inputs.

required
targets Dict[str, Any]

Targets.

required

Returns:

Type Description
Tuple[Dict[str, Any], Dict[str, Any]]

Tuple[Dict[str, torch.Tensor], Dict[str, torch.Tensor]]: Inputs, targets (transformed).

Source code in lightning_boost/modules/preprocessing/composite_transform.py
def __call__(
    self, inputs: Dict[str, Any], targets: Dict[str, Any]
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
    """
    Performs the given transforms in the specified order for inputs and targets.

    Args:
        inputs (Dict[str, Any]): Inputs.
        targets (Dict[str, Any]): Targets.

    Returns:
        Tuple[Dict[str, torch.Tensor], Dict[str, torch.Tensor]]: Inputs, targets (transformed).
    """

    for transform in self.transforms:
        inputs, targets = transform(inputs, targets)

    return inputs, targets