deepr.utils.to_flat_tuple

deepr.utils.to_flat_tuple(items)[source]

Convert nested list, tuples and generators to a flat tuple.

Flatten any nested structure of items. Will unpack lists, tuple and generators. Any other type will not be unpacked, meaning that you can safely use this function on other iterable types like strings or tf.Tensor. For example:

to_flat_tuple(1)  # (1,)
to_flat_tuple("hello")  # ("hello",)
to_flat_tuple(tf.ones([2, 2]))  # (tf.ones([2, 2]),)
to_flat_tuple((x for x in range(2)))  # (0, 1)
to_flat_tuple((1, 2))  # (1, 2)
to_flat_tuple(((0, 1), 2))  # (0, 1, 2)
Parameters:

items (Item, Tuple, List or Generator (nested)) – Items to transform to a flat tuple

Returns:

Return type:

Tuple