ToArray#

class bayesflow.adapters.transforms.ToArray[source]#

Bases: ElementwiseTransform

Checks provided data for any non-arrays and converts them to numpy arrays.

This ensures all data is in a format suitable for training.

Examples

>>> ta = bf.adapters.transforms.ToArray()
>>> a = [1, 2, 3, 4]
>>> ta.forward(a)
    array([1, 2, 3, 4])
>>> b = [[1, 2], [3, 4]]
>>> ta.forward(b)
    array([[1, 2],
        [3, 4]])
classmethod from_config(config: dict, custom_objects=None) ToArray[source]#
get_config() dict[source]#
forward(data: any, **kwargs) ndarray[source]#
inverse(data: ndarray, **kwargs) any[source]#
__call__(data: ndarray, inverse: bool = False, **kwargs) ndarray#

Call self as a function.