KerasTransform#

class bayesflow.adapters.transforms.KerasTransform(forward: str, inverse: str = None)[source]#

Bases: ElementwiseTransform

A class to apply element-wise transformations using named keras.ops functions.

Attributes:
_forwardstr

The name of the keras.ops function to apply in the forward transformation.

_inversestr

The name of the keras.ops function to apply in the inverse transformation.

Initializes the KerasTransform with specified forward and inverse functions.

Parameters:
forwardstr

The name of the keras.ops function to use for the forward transformation.

inversestr, optional

The name of the keras.ops function to use for the inverse transformation. By default, the inverse is inferred from the forward argument for supported methods.

INVERSE_METHODS = {'arctan': 'tan', 'exp': 'log', 'expm1': 'log1p', 'log': 'exp', 'log1p': 'expm1', 'reciprocal': 'reciprocal', 'sqrt': 'square', 'square': 'sqrt', 'tan': 'arctan'}#

Dict of function names that support automatic selection of their inverse.

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

Call self as a function.

classmethod from_config(config: dict, custom_objects=None)#