pyhgf.model.hybrid.EquinoxAdapter#
- class pyhgf.model.hybrid.EquinoxAdapter(forward_fn, backward_fn)[source]#
A frozen part: a fixed calculation that routes errors but never learns.
Declares a forward function and its hand-derived backward companion — no automatic differentiation is involved at any point:
forward_fn(x) -> (y, cache)computes the output for a batch and returns whatever the backward formula needs;backward_fn(cache, error) -> error_intranslates the error at the output into the error at the input, using only the cache.
Error convention
Both forward_fn and backward_fn use the descent-error convention (see
pyhgf.model.error_types):forward_fn receives arrays in the pipeline’s usual format
backward_fn receives
DescentError(positive = signal too high) and returns the same convention
The hand-derived backward formula must respect this convention: if the function is
y = f(x)and loss isL(y), thenbackward_fnshould return∂L/∂x = (∂L/∂y) @ (∂y/∂x)^T.Use the ready-made constructors
gelu_adapter()andlayer_norm_adapter()for the standard Transformer pieces.- Parameters:
Methods
__init__(forward_fn, backward_fn)init_state()Return the empty state pytree (frozen parts have no state).