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:
  • x (NDArray[Shape[length], complex]) – The iterable to be unpacked.

  • shapes (Iterable[Iterable[int]]) – The shapes of the tensors to be unpacked into.

Returns:

A list of TensorFlow tensors of the given shapes.

Return type:

list

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 shapes to 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 InvertibleFunction with the specified parameters pre-specified.

RETURN TYPE:

InvertibleFunction

unpack.compose()

Composes the unpack() with another InvertibleFunction to create a new InvertibleFunction along 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 InvertibleFunction be be called first. The output of this InvertibleFunction will be passed to unpack().

  • shapes (Iterable[Iterable[int]]) — The shapes of the tensors to be unpacked into.

RETURNS:

A new InvertibleFunction that is the composition of the two functions.

RETURN TYPE:

InvertibleFunction