Skip to content

Transforms: Squash Shapes and Axis Warps


BoundTransform

from jaxhybridmodels.transforms import BoundTransform  ·  also re-exported as jaxhybridmodels.BoundTransform

python
BoundTransform(
    forward: ForwardRef('Callable[[Array], Array]'),
    inverse: ForwardRef('Callable[[Array], Array]'),
    inverse_slope: ForwardRef('Callable[[Array], Array]'),
    knee: ForwardRef('float'),
)

A squash from the whole real line into (0, 1), with its inverse and metadata.

Attributes

FieldTypeDescription
forwardCallableR -> (0, 1). Applied by from_latent on the way from latent to physical.
inverseCallable(0, 1) -> R. Applied by to_latent on the way back.
inverse_slopeCallabled(inverse)/ds. Builds the linear continuation that keeps to_latent differentiable for inputs that fall outside the box.
kneefloatThe latent at which forward reaches 0.95, where the physical value enters the outer 5% of its box. Default for BoundScaler.z_knee. It must come from the transform: reusing sigmoid's 2.944 for softsign would start charging at 12.5% from the bound instead of 5%.

Source


BOUND_TRANSFORMS

from jaxhybridmodels.transforms import BOUND_TRANSFORMS  ·  also re-exported as jaxhybridmodels.BOUND_TRANSFORMS

python
BOUND_TRANSFORMS = {
  'algebraic': BoundTransform
  'sigmoid': BoundTransform
  'softsign': BoundTransform
}

dict() -> new empty dictionary

dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)


register_bound_transform()

from jaxhybridmodels.transforms import register_bound_transform  ·  also re-exported as jaxhybridmodels.register_bound_transform

python
register_bound_transform(name: 'str', transform: 'BoundTransform') -> 'None'

Register a squash under name for use by BoundScaler.

Mirrors register_solver. A scaler stores only the name, so a custom transform must be registered before a saved scaler that references it can be rebuilt. Re-registering an existing name overwrites without warning.

Source


Warp

from jaxhybridmodels.transforms import Warp  ·  also re-exported as jaxhybridmodels.Warp

python
Warp(
    forward: ForwardRef('Callable[[ArrayLike], Array]'),
    inverse: ForwardRef('Callable[[ArrayLike], Array]'),
    requires_positive: ForwardRef('bool'),
)

A monotone change of coordinate applied to the physical axis before normalising.

The warp runs first, then the box is normalised to [0, 1] in warped coordinates, then the transform's inverse takes it to the latent.

Attributes

FieldTypeDescription
forwardCallablePhysical to warped coordinate. Must accept a Python float as well as an array, because warp_bounds calls it on the static box edges when a scaler is constructed.
inverseCallableWarped coordinate back to physical. Must invert forward exactly on the declared box.
requires_positiveboolWhether the warp is undefined at or below zero. Checked against the declared bounds at construction, where it raises a useful error rather than a silent nan inside a compiled solve.

Source


WARPS

from jaxhybridmodels.transforms import WARPS  ·  also re-exported as jaxhybridmodels.WARPS

python
WARPS = {
  'linear': Warp
  'log': Warp
  'log10': Warp
}

dict() -> new empty dictionary

dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)


register_warp()

from jaxhybridmodels.transforms import register_warp  ·  also re-exported as jaxhybridmodels.register_warp

python
register_warp(name: 'str', warp: 'Warp') -> 'None'

Register an axis warp under name for use by BoundScaler.

Same contract as register_bound_transform. A warp must be monotone on the declared box and inverse must undo forward there, or the scaler's round trip stops being the identity.

Source

Released under the BSD-3-Clause License.