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 log_det_jac(self, data: np.ndarray, inverse: bool = False, **kwargs) -> np.ndarray | None:
return None