Skip to main content

omnibias.jax.architectures.ftc_net

0.5.0rc1Release candidatePython >=3.10Apache-2.0

JAX activation derivatives, functional network jets, direct contractions, and parameter-differentiable numerical models.

import omnibias.jax.architectures.ftc_net
Module contract & mathematical conventions

FTC-Net + dual-FTC loss (jax; theory 09-03 / 09-17).

The cell is the integral role. The derivative head is FTC of the same window. The founding bias collapse (delta -> 0) is the collapse head I / delta. Temperature collapse (beta -> inf, feasibility) does not appear. Do not conflate the two.

Shared formulas do not imply universal floating-point identity. Verify dtype, shape, derivative-order support, and the stated numerical assumptions for the path you use.

Imports & aliases​

These names share a definition with another public module. Follow a name for its full contract, parameters, and examples.

Import from this moduleCanonical reference
DISCLAIMERomnibias.core.ftc.DISCLAIMER
DualFTCConfigomnibias.core.ftc.DualFTCConfig
FTCNetConfigomnibias.core.ftc.FTCNetConfig
honesty_payloadomnibias.core.ftc.honesty_payload
worked_exampleomnibias.core.ftc.worked_example
CLASS

FTCNet​

omnibias.jax.architectures.FTCNetSource ↗
class FTCNet

Config holder; evaluation is the closed-form pack sum in omnibias.core.ftc.

Parameters

NameType & defaultContract
configpositional-or-keywordFTCNetConfig | NoneDefault: NoneSee the operation contract and implementation below.
Executed regression · g1 matches core

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_g1_matches_core() -> None:
    x = jnp.asarray(0.0)
    w = jnp.asarray(1.0)
    lo = jnp.asarray(-0.1)
    hi = jnp.asarray(0.1)
    integral, deriv, collapse = ftc_block(x, w, lo, hi)
    ex = worked_example()
    assert float(integral) == ex["I"]
    assert float(deriv) == ex["dI"]
    assert float(collapse) == ex["collapse"]
    assert FTCNet(FTCNetConfig()).config.window == 0.6
python -m pytest "packages/omnibias-jax/tests/test_ftc_net.py::test_g1_matches_core" -q

Fields & methods

__init__method
__init__(self, config: FTCNetConfig | None=None) -> None

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
configpositional-or-keywordFTCNetConfig | NoneDefault: NoneSee the operation contract and implementation below.

Returns: None

Executed regression · g1 matches core

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_g1_matches_core() -> None:
    x = jnp.asarray(0.0)
    w = jnp.asarray(1.0)
    lo = jnp.asarray(-0.1)
    hi = jnp.asarray(0.1)
    integral, deriv, collapse = ftc_block(x, w, lo, hi)
    ex = worked_example()
    assert float(integral) == ex["I"]
    assert float(deriv) == ex["dI"]
    assert float(collapse) == ex["collapse"]
    assert FTCNet(FTCNetConfig()).config.window == 0.6
python -m pytest "packages/omnibias-jax/tests/test_ftc_net.py::test_g1_matches_core" -q
Method implementation
    def __init__(self, config: FTCNetConfig | None = None) -> None:
        self.config = FTCNetConfig() if config is None else config
View source ↗
configattribute
config = FTCNetConfig() if config is None else config

Public instance attribute assigned by __init__. The source assignment is config = FTCNetConfig() if config is None else config; it describes instance state, not a literal constructor default.

View source ↗
Read the implementation
class FTCNet:
    """Config holder; evaluation is the closed-form pack sum in ``omnibias.core.ftc``."""

    def __init__(self, config: FTCNetConfig | None = None) -> None:
        self.config = FTCNetConfig() if config is None else config
Other public import paths
  • omnibias.jax.architectures.FTCNet
  • omnibias.jax.architectures.ftc_net.FTCNet
FUNCTION

dual_ftc_loss​

omnibias.jax.architectures.dual_ftc_lossSource ↗
dual_ftc_loss(I_vals: Sequence[float] | Array, dI_vals: Sequence[float] | Array, f_vals: Sequence[float] | Array, F_vals: Sequence[float] | Array, *, config: DualFTCConfig | None=None, I_a: float | None=None) -> core_ftc.DualFTCResult

The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.

Parameters

NameType & defaultContract
I_valspositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
dI_valspositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
f_valspositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
F_valspositional-or-keywordSequence[float] | ArrayRequiredSee the operation contract and implementation below.
configkeyword-onlyDualFTCConfig | NoneDefault: NoneSee the operation contract and implementation below.
I_akeyword-onlyfloat | NoneDefault: NoneSee the operation contract and implementation below.
Returnscore_ftc.DualFTCResult
Read the implementation
def dual_ftc_loss(
    I_vals: Sequence[float] | Array,
    dI_vals: Sequence[float] | Array,
    f_vals: Sequence[float] | Array,
    F_vals: Sequence[float] | Array,
    *,
    config: DualFTCConfig | None = None,
    I_a: float | None = None,
) -> core_ftc.DualFTCResult:
    def _as_list(v: Sequence[float] | Array) -> list[float]:
        if hasattr(v, "reshape"):
            return [float(x) for x in jnp.asarray(v).reshape(-1).tolist()]
        return [float(x) for x in v]

    return core_ftc.dual_ftc_loss(
        _as_list(I_vals),
        _as_list(dI_vals),
        _as_list(f_vals),
        _as_list(F_vals),
        config=core_ftc.DEFAULT_DUAL if config is None else config,
        I_a=I_a,
    )
Other public import paths
  • omnibias.jax.architectures.dual_ftc_loss
  • omnibias.jax.architectures.ftc_net.dual_ftc_loss
FUNCTION

ftc_block​

omnibias.jax.architectures.ftc_blockSource ↗
ftc_block(x: Array, w: Array, b_lo: Array, b_hi: Array, *, activation: str='sigmoid') -> tuple[Array, Array, Array]

mathematically equivalent to omnibias.core.ftc.ftc_block on scalars.

Backend scope: this identifies the corresponding mathematical construction. It does not guarantee bitwise-equal floating-point results across devices, compilers, dtypes, or backend versions. Validate the selected path with an appropriate absolute and relative tolerance.

Parameters

NameType & defaultContract
xpositional-or-keywordArrayRequiredSee the operation contract and implementation below.
wpositional-or-keywordArrayRequiredSee the operation contract and implementation below.
b_lopositional-or-keywordArrayRequiredSee the operation contract and implementation below.
b_hipositional-or-keywordArrayRequiredSee the operation contract and implementation below.
activationkeyword-onlystrDefault: 'sigmoid'See the operation contract and implementation below.
Returnstuple[Array, Array, Array]
Executed regression · g1 matches core

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_g1_matches_core() -> None:
    x = jnp.asarray(0.0)
    w = jnp.asarray(1.0)
    lo = jnp.asarray(-0.1)
    hi = jnp.asarray(0.1)
    integral, deriv, collapse = ftc_block(x, w, lo, hi)
    ex = worked_example()
    assert float(integral) == ex["I"]
    assert float(deriv) == ex["dI"]
    assert float(collapse) == ex["collapse"]
    assert FTCNet(FTCNetConfig()).config.window == 0.6
python -m pytest "packages/omnibias-jax/tests/test_ftc_net.py::test_g1_matches_core" -q
Regression example · g4 worked example bit identical

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_g4_worked_example_bit_identical() -> None:
    torch.set_default_dtype(torch.float64)
    ti, td, tc = torch_ftc_block(
        torch.tensor(0.0), torch.tensor(1.0), torch.tensor(-0.1), torch.tensor(0.1)
    )
    ji, jd, jc = jax_ftc_block(
        jnp.asarray(0.0), jnp.asarray(1.0), jnp.asarray(-0.1), jnp.asarray(0.1)
    )
    assert float(ti) == float(ji)
    assert float(td) == float(jd)
    assert float(tc) == float(jc)
python -m pytest tests/test_ftc_net_parity.py -k test_g4_worked_example_bit_identical -q
Read the implementation
def ftc_block(
    x: Array,
    w: Array,
    b_lo: Array,
    b_hi: Array,
    *,
    activation: str = "sigmoid",
) -> tuple[Array, Array, Array]:
    """Bit-identical to :func:`omnibias.core.ftc.ftc_block` on scalars."""
    xs = jnp.asarray(x).reshape(-1).tolist()
    ws = jnp.asarray(w).reshape(-1).tolist()
    los = jnp.asarray(b_lo).reshape(-1).tolist()
    his = jnp.asarray(b_hi).reshape(-1).tolist()
    n = max(len(xs), len(ws), len(los), len(his))

    def _at(vals: list[float], i: int) -> float:
        return vals[0] if len(vals) == 1 else vals[i]

    integrals: list[float] = []
    derivs: list[float] = []
    collapses: list[float] = []
    for i in range(n):
        integral, deriv, collapse = core_ftc.ftc_block(
            _at(xs, i), _at(ws, i), _at(los, i), _at(his, i), activation=activation
        )
        integrals.append(integral)
        derivs.append(deriv)
        collapses.append(collapse)
    dtype = jnp.asarray(x).dtype
    shape = jnp.asarray(x).shape
    if shape == ():
        return (
            jnp.asarray(integrals[0], dtype=dtype),
            jnp.asarray(derivs[0], dtype=dtype),
            jnp.asarray(collapses[0], dtype=dtype),
        )
    return (
        jnp.asarray(integrals, dtype=dtype).reshape(shape),
        jnp.asarray(derivs, dtype=dtype).reshape(shape),
        jnp.asarray(collapses, dtype=dtype).reshape(shape),
    )
Other public import paths
  • omnibias.jax.architectures.ftc_block
  • omnibias.jax.architectures.ftc_net.ftc_block