ReduceTuple

class hybrid_learning.datasets.transforms.tuple_transforms.ReduceTuple(trafo, reduction)[source]

Bases: Transform

Transform an unpacked input tuple and then reduce it to one value using a reduction func. This is essentially the concatenation of two functions, but with type hints assuming a single tensor output, and with better One example would reduction by a loss function.

Note

Attribute access is handed over to reduction if the attribute cannot be found in this instance. This is intended to ease wrapping of metric functions.

Public Data Attributes:

settings

Settings to reproduce the instance.

Inherited from : py: class:Transform

IDENTITY_CLASS

The identity class or classes for composition / addition.

settings

Settings to reproduce the instance.

Public Methods:

apply_to(*inps)

Apply the transformation and the the reduction.

Inherited from : py: class:Transform

apply_to(*inps)

Apply the transformation and the the reduction.

Special Methods:

__getattr__(k)

Pass attribute requests over to reduction.

__init__(trafo, reduction)

Init.

__radd__(other)

Make it possible to prepend trafos via left addition.

Inherited from : py: class:Transform

__repr__()

Return repr(self).

__eq__(other)

Return self==value.

__copy__()

Return a shallow copy of self using settings.

__add__(other)

Return a flat composition of self with other.

__radd__(other)

Make it possible to prepend trafos via left addition.

__call__(*inps)

General call to the transformation.


Parameters
__getattr__(k)[source]

Pass attribute requests over to reduction.

__init__(trafo, reduction)[source]

Init.

Parameters
  • trafo (Callable) – a tuple transform that accepts an unpacked tuple of inputs and returns a same-length tuple of outputs

  • reduction (Callable) – the loss to apply after application of trafo

__radd__(other)[source]

Make it possible to prepend trafos via left addition.

Returns

new ReduceTuple instance with the new trafo prepended to the old one

Parameters

other (Optional[TupleTransforms]) –

Return type

ReduceTuple

apply_to(*inps)[source]

Apply the transformation and the the reduction.

Parameters

inps (Tensor) –

Return type

Tensor

reduction: Callable[[...], Tensor]

Reduction function to reduce a tuple to a single value.

property settings: Dict[str, Any]

Settings to reproduce the instance.

trafo: Callable

The tuple transformation to apply before reducing the tuple.