Squeeze#

class bayesflow.adapters.transforms.Squeeze(*, axis: int | Sequence[int])[source]#

Bases: ElementwiseTransform

Squeeze dimensions of an array.

Parameters:
axisint or tuple

The axis to squeeze. As the number of batch dimensions might change, we advise using negative numbers (i.e., indexing from the end instead of the start).

Examples

shape (3, 1) array:

>>> a = np.array([[1], [2], [3]])
>>> sq = bf.adapters.transforms.Squeeze(axis=-1)
>>> sq.forward(a).shape
(3,)

It is recommended to precede this transform with a ToArray transform.

get_config() dict[source]#
forward(data: ndarray, **kwargs) ndarray[source]#
inverse(data: ndarray, **kwargs) ndarray[source]#
__call__(data: ndarray, inverse: bool = False, **kwargs) ndarray#

Call self as a function.

classmethod from_config(config: dict, custom_objects=None)#
log_det_jac(data: ndarray, inverse: bool = False, **kwargs) ndarray | None#