omnibias.jax.weight_loss_jet
JAX activation derivatives, functional network jets, direct contractions, and parameter-differentiable numerical models.
import omnibias.jax.weight_loss_jetModule contract & mathematical conventions
Closed-form one-layer weight-space loss jets, JAX twin.
Host-side conversion into omnibias.core.weight_loss_jet. Bit-identical
to the torch twin on the same floats. Do not jit the driver.
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 module | Canonical reference |
|---|---|
WeightLossJetSpec | omnibias.core.WeightLossJetSpec |
honesty_payload | omnibias.core.weight_loss_jet.honesty_payload |
one_layer_param_count | omnibias.core.one_layer_param_count |
pack_one_layer_params | omnibias.core.pack_one_layer_params |
unpack_one_layer_params | omnibias.core.unpack_one_layer_params |
one_layer_loss
omnibias.jax.one_layer_lossSource ↗one_layer_loss(features: Array, targets: Array, params: Array, hidden: int, dim: int, activation: str='tanh') -> floatThe module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
featurespositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
targetspositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
paramspositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
hiddenpositional-or-keyword | intRequired | See the operation contract and implementation below. |
dimpositional-or-keyword | intRequired | See the operation contract and implementation below. |
activationpositional-or-keyword | strDefault: 'tanh' | See the operation contract and implementation below. |
floatRead the implementation
def one_layer_loss(
features: Array,
targets: Array,
params: Array,
hidden: int,
dim: int,
activation: str = "tanh",
) -> float:
return core.one_layer_loss(
_rows(features), _vec(targets), _vec(params), hidden, dim, activation
)Other public import paths
omnibias.jax.one_layer_lossomnibias.jax.weight_loss_jet.one_layer_loss
one_layer_loss_grad
omnibias.jax.one_layer_loss_gradSource ↗one_layer_loss_grad(features: Array, targets: Array, params: Array, hidden: int, dim: int, activation: str='tanh') -> list[float]The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
featurespositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
targetspositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
paramspositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
hiddenpositional-or-keyword | intRequired | See the operation contract and implementation below. |
dimpositional-or-keyword | intRequired | See the operation contract and implementation below. |
activationpositional-or-keyword | strDefault: 'tanh' | See the operation contract and implementation below. |
list[float]Read the implementation
def one_layer_loss_grad(
features: Array,
targets: Array,
params: Array,
hidden: int,
dim: int,
activation: str = "tanh",
) -> list[float]:
return core.one_layer_loss_grad(
_rows(features), _vec(targets), _vec(params), hidden, dim, activation
)Other public import paths
omnibias.jax.one_layer_loss_gradomnibias.jax.weight_loss_jet.one_layer_loss_grad
one_layer_loss_hessian
omnibias.jax.one_layer_loss_hessianSource ↗one_layer_loss_hessian(features: Array, targets: Array, params: Array, hidden: int, dim: int, activation: str='tanh', *, max_params: int=256) -> list[list[float]]The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
featurespositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
targetspositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
paramspositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
hiddenpositional-or-keyword | intRequired | See the operation contract and implementation below. |
dimpositional-or-keyword | intRequired | See the operation contract and implementation below. |
activationpositional-or-keyword | strDefault: 'tanh' | See the operation contract and implementation below. |
max_paramskeyword-only | intDefault: 256 | See the operation contract and implementation below. |
list[list[float]]Read the implementation
def one_layer_loss_hessian(
features: Array,
targets: Array,
params: Array,
hidden: int,
dim: int,
activation: str = "tanh",
*,
max_params: int = 256,
) -> list[list[float]]:
return core.one_layer_loss_hessian(
_rows(features),
_vec(targets),
_vec(params),
hidden,
dim,
activation,
max_params=max_params,
)Other public import paths
omnibias.jax.one_layer_loss_hessianomnibias.jax.weight_loss_jet.one_layer_loss_hessian
one_layer_loss_jet
omnibias.jax.one_layer_loss_jetSource ↗one_layer_loss_jet(features: Array, targets: Array, params: Array, direction: Array, *, order: int, hidden: int, dim: int, activation: str='tanh') -> list[float]φ^(k)(0) via the shared core assembler.
Parameters
| Name | Type & default | Contract |
|---|---|---|
featurespositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
targetspositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
paramspositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
directionpositional-or-keyword | ArrayRequired | See the operation contract and implementation below. |
orderkeyword-only | intRequired | See the operation contract and implementation below. |
hiddenkeyword-only | intRequired | See the operation contract and implementation below. |
dimkeyword-only | intRequired | See the operation contract and implementation below. |
activationkeyword-only | strDefault: 'tanh' | See the operation contract and implementation below. |
list[float]Regression example · torch jax core loss jet parity
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_torch_jax_core_loss_jet_parity() -> None:
torch = pytest.importorskip("torch")
jax = pytest.importorskip("jax")
jax.config.update("jax_enable_x64", True)
import jax.numpy as jnp
from omnibias.jax.weight_loss_jet import one_layer_loss_jet as jax_jet
from omnibias.torch.weight_loss_jet import one_layer_loss_jet as torch_jet
torch.set_default_dtype(torch.float64)
expected = core_jet(
_XS,
_YS,
_THETA,
_DIR,
order=3,
hidden=2,
dim=2,
activation="tanh",
)
t_out = torch_jet(
torch.tensor(_XS, dtype=torch.float64),
torch.tensor(_YS, dtype=torch.float64),
torch.tensor(_THETA, dtype=torch.float64),
torch.tensor(_DIR, dtype=torch.float64),
order=3,
hidden=2,
dim=2,
activation="tanh",
)
j_out = jax_jet(
jnp.asarray(_XS, dtype=jnp.float64),
jnp.asarray(_YS, dtype=jnp.float64),
jnp.asarray(_THETA, dtype=jnp.float64),
jnp.asarray(_DIR, dtype=jnp.float64),
order=3,
hidden=2,
dim=2,
activation="tanh",
)
assert t_out == expected
assert j_out == expectedpython -m pytest tests/test_weight_loss_jet_parity.py -k test_torch_jax_core_loss_jet_parity -qRead the implementation
def one_layer_loss_jet(
features: Array,
targets: Array,
params: Array,
direction: Array,
*,
order: int,
hidden: int,
dim: int,
activation: str = "tanh",
) -> list[float]:
"""``φ^(k)(0)`` via the shared core assembler."""
return core.one_layer_loss_jet(
_rows(features),
_vec(targets),
_vec(params),
_vec(direction),
order=order,
hidden=hidden,
dim=dim,
activation=activation,
)Other public import paths
omnibias.jax.one_layer_loss_jetomnibias.jax.weight_loss_jet.one_layer_loss_jet
one_layer_newton_direction
omnibias.jax.one_layer_newton_directionSource ↗one_layer_newton_direction(grad: Array | Sequence[float], hess: Array | Sequence[Sequence[float]], *, damping: float=1e-06) -> list[float]The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
gradpositional-or-keyword | Array | Sequence[float]Required | See the operation contract and implementation below. |
hesspositional-or-keyword | Array | Sequence[Sequence[float]]Required | See the operation contract and implementation below. |
dampingkeyword-only | floatDefault: 1e-06 | See the operation contract and implementation below. |
list[float]Read the implementation
def one_layer_newton_direction(
grad: Array | Sequence[float],
hess: Array | Sequence[Sequence[float]],
*,
damping: float = 1e-6,
) -> list[float]:
if isinstance(hess, Array):
rows = [[float(v) for v in row] for row in hess]
else:
rows = [[float(v) for v in row] for row in hess]
return core.one_layer_newton_direction(_vec(grad), rows, damping=damping)Other public import paths
omnibias.jax.one_layer_newton_directionomnibias.jax.weight_loss_jet.one_layer_newton_direction