SerializableCustomTransform#

class bayesflow.adapters.transforms.SerializableCustomTransform(*, forward: Callable[[ndarray, ...], ndarray], inverse: Callable[[ndarray, ...], ndarray])[source]#

Bases: ElementwiseTransform

Transforms a parameter using a pair of registered serializable forward and inverse functions.

Parameters:
forwardfunction, no lambda

Registered serializable function to transform the data in the forward pass. For the adapter to be serializable, this function has to be serializable as well (see Notes). Therefore, only proper functions and no lambda functions can be used here.

inversefunction, no lambda

Function to transform the data in the inverse pass. For the adapter to be serializable, this function has to be serializable as well (see Notes). Therefore, only proper functions and no lambda functions can be used here.

Raises:
ValueError

When the provided functions are not registered serializable functions.

Notes

Important: The forward and inverse functions have to be registered with Keras. To do so, use the @keras.saving.register_keras_serializable decorator. They must also be registered (and identical) when loading the adapter at a later point in time.

classmethod from_config(config: dict, custom_objects=None) SerializableCustomTransform[source]#
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.