AsSimplex#
- class bayesflow.adapters.transforms.AsSimplex(*, axis: int = -1, method: str = 'default')[source]#
Bases:
ElementwiseTransformConstrains neural network predictions of a data variable to a unit simplex, so that the constrained representation is non-negative and sums to one along the given axis.
- Parameters:
- axisint, optional
The axis of the simplex-constrained data along which values sum to one over all K elements. The corresponding unconstrained representation has a size of K-1 along this axis.
- methodstr, optional
Method by which to transform between the K dimensional simplex space and the K-1 dimensional unconstrained space. - “default” / “simplex”: sum-to-zero (orthogonal basis) transform followed by a softmax transform. Plain softmax is not invertible (shifting all values by a constant results in the same inverse). The sum-to-zero removes this issue. - “stick”: an invertible stick-breaking logistic transform.
Examples
>>> adapter = bf.Adapter().as_simplex("probs")