Source code for bayesflow.adapters.transforms.elementwise_transform

import numpy as np

from bayesflow.utils.serialization import serializable, deserialize


[docs] @serializable("bayesflow.adapters") class ElementwiseTransform: """Base class on which other transforms are based"""
[docs] def __call__(self, data: np.ndarray, inverse: bool = False, **kwargs) -> np.ndarray: if inverse: return self.inverse(data, **kwargs) return self.forward(data, **kwargs)
[docs] @classmethod def from_config(cls, config: dict, custom_objects=None): return cls(**deserialize(config, custom_objects=custom_objects))
[docs] def get_config(self) -> dict: raise NotImplementedError
[docs] def forward(self, data: np.ndarray, **kwargs) -> np.ndarray: raise NotImplementedError
[docs] def inverse(self, data: np.ndarray, **kwargs) -> np.ndarray: raise NotImplementedError
[docs] def log_det_jac(self, data: np.ndarray, inverse: bool = False, **kwargs) -> np.ndarray | None: return None