UnfoldTuple

class hybrid_learning.datasets.transforms.tuple_transforms.UnfoldTuple[source]

Bases: Transform

Convenience trafo that takes an iterable and returns it as tuple. Needed e.g. when unravelling a nested tuple for a composition of TupleTransforms:

>>> from hybrid_learning.datasets.transforms import UnfoldTuple, ToTensor
>>> c = UnfoldTuple() + OnTarget(UnfoldTuple() + OnTarget(ToTensor()))
>>> nested_tuple = ('desc', ('inp', 1))
>>> nested_tuple
('desc', ('inp', 1))
>>> c(nested_tuple)
('desc', ('inp', tensor(1)))

Public Data Attributes:

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(tup)

Return the given iterable as tuple.

Inherited from : py: class:Transform

apply_to(tup)

Return the given iterable as tuple.

Special Methods:

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)

Return a flat composition of other and self.

__call__(*inps)

General call to the transformation.


apply_to(tup)[source]

Return the given iterable as tuple.

Parameters

tup (Iterable) –

Return type

Tuple