omnibias.keras.fastpath.hermite
Keras 3 operator layers and activation paths implemented with keras.ops for TensorFlow, JAX, or Torch.
import omnibias.keras.fastpath.hermiteModule contract & mathematical conventions
Closed-form derivatives of the Gaussian activation via probabilist's
Hermite polynomials, evaluated with keras.ops.
Let g(z) = exp(-z^2/2). Then g^(n)(z) = (-1)^n He_n(z) g(z),
where He_n obeys He_0 = 1, He_1 = z, He_{n+1} = z He_n - n He_{n-1}.
Coefficients come from the shared omnibias.core.polynomials.
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 |
|---|---|
hermite_coeffs | omnibias.core.hermite_coeffs |
gaussian_forward
omnibias.keras.fastpath.gaussian_forwardSource ↗gaussian_forward(z: Any) -> Anyg(z) = exp(-z^2/2).
Parameters
| Name | Type & default | Contract |
|---|---|---|
zpositional-or-keyword | AnyRequired | See the operation contract and implementation below. |
AnyExecuted regression · fastpath order zero is forward
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_fastpath_order_zero_is_forward(fn) -> None:
z = np.linspace(-2.0, 2.0, 11)
out0 = _np(fn(_t(z), 0))
assert out0.shape == z.shape
assert np.all(np.isfinite(out0))python -m pytest "packages/omnibias-keras/tests/test_fastpath_correctness.py::test_fastpath_order_zero_is_forward[gaussian_nth_derivative]" -qRead the implementation
def gaussian_forward(z: Any) -> Any:
"""``g(z) = exp(-z^2/2)``."""
return ops.exp(-0.5 * z * z)Other public import paths
omnibias.keras.fastpath.gaussian_forwardomnibias.keras.fastpath.hermite.gaussian_forward
gaussian_nth_derivative
omnibias.keras.fastpath.gaussian_nth_derivativeSource ↗gaussian_nth_derivative(z: Any, n: int) -> Anyg^(n)(z) via g^(n)(z) = (-1)^n He_n(z) g(z).
Parameters
| Name | Type & default | Contract |
|---|---|---|
zpositional-or-keyword | AnyRequired | See the operation contract and implementation below. |
npositional-or-keyword | intRequired | See the operation contract and implementation below. |
AnyExplicit validation & failure cases
- When
n < 0, raisesValueError(f'order n must be >= 0, got {n}').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Executed regression · negative order raises
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_negative_order_raises(fn) -> None:
with pytest.raises(ValueError):
fn(_t(np.zeros(3)), -1)python -m pytest "packages/omnibias-keras/tests/test_fastpath_correctness.py::test_negative_order_raises[gaussian_nth_derivative]" -qRegression example · fastpath order zero is forward
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_fastpath_order_zero_is_forward(fn) -> None:
z = np.linspace(-2.0, 2.0, 11)
out0 = _np(fn(_t(z), 0))
assert out0.shape == z.shape
assert np.all(np.isfinite(out0))python -m pytest packages/omnibias-keras/tests/test_fastpath_correctness.py -k test_fastpath_order_zero_is_forward -qRead the implementation
def gaussian_nth_derivative(z: Any, n: int) -> Any:
"""``g^(n)(z)`` via ``g^(n)(z) = (-1)^n He_n(z) g(z)``."""
if n < 0:
raise ValueError(f"order n must be >= 0, got {n}")
g = gaussian_forward(z)
if n == 0:
return g
poly = _horner(hermite_coeffs(n), z)
sign = -1.0 if (n & 1) else 1.0
return sign * poly * gOther public import paths
omnibias.keras.fastpath.gaussian_nth_derivativeomnibias.keras.fastpath.hermite.gaussian_nth_derivative