unpack¶
- qugradlab.pulses.invertible_functions.packaging.unpack(x: Iterable, shapes: Iterable[Iterable[int]]) list[source]¶
Unpacks an input iterable x into TensorFlow tensors of the given shapes.
- Parameters:
- Returns:
A list of TensorFlow tensors of the given shapes.
- Return type:
- unpack.inverse()¶
Packs the list of input tensors into a single TensorFlow tensor.
- PARAMETERS:
tensors (list) — The TensorFlow tensors to be packed
- RETURNS:
A TensorFlow tensor with 1 axis consisting of all the input tensors flattened and concatenated.
- RETURN TYPE:
Any
- unpack.specify_parameters()¶
Allows the
shapesto be pre-specified. This removes shapes from the call signature.- PARAMETERS:
shapes (Iterable[Iterable[int]], optional) — The shapes of the tensors to be unpacked into.
- RETURNS:
A new
InvertibleFunctionwith the specified parameters pre-specified.- RETURN TYPE:
InvertibleFunction
- unpack.compose()¶
Composes the
unpack()with anotherInvertibleFunctionto create a newInvertibleFunctionalong with the composed inverse. That is the following assertions should hold:assert unpack.compose(g, *args, **kwargs)(x, *g_args, **g_kwargs) == unpack(g(x, *g_args, **g_kwargs), *args, **kwargs)
for all inputs
x.- PARAMETERS:
inner_invertible_function (InvertibleFunction) — The
InvertibleFunctionbe be called first. The output of thisInvertibleFunctionwill be passed tounpack().shapes (Iterable[Iterable[int]]) — The shapes of the tensors to be unpacked into.
- RETURNS:
A new
InvertibleFunctionthat is the composition of the two functions.- RETURN TYPE:
InvertibleFunction