pack¶
- qugradlab.pulses.invertible_functions.packaging.pack(tensors: list) Any[source]¶
Packs the list of input tensors into a single TensorFlow tensor.
- Parameters:
tensors (list) – The list of TensorFlow tensors to be packed
- Returns:
A TensorFlow tensor with 1 axis consisting of all the input tensors flattened and concatenated.
- Return type:
TensorFlow Tensor
- pack.inverse()¶
Unpacks an input iterable x into TensorFlow tensors of the given shapes.
- PARAMETERS:
x (Iterable) — The iterable to be unpacked.
shapes (Iterable[Iterable[int]]) — The shapes of the tensors to be unpacked into.
- RETURNS:
A TensorFlow tensor with 1 axis consisting of all the input tensors flattened and concatenated.
- RETURN TYPE:
list
- pack.specify_parameters()¶
Allows the
shapesto be pre-specified. This removes shapes from the call signature ofinverse().- 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
- pack.compose()¶
Composes the
pack()with anotherInvertibleFunctionto create a newInvertibleFunctionalong with the composed inverse. That is the following assertions should hold:assert pack.compose(g, *args, **kwargs)(x, *g_args, **g_kwargs) == pack(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 topack().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