omnibias.keras.activations.proximal
Keras 3 operator layers and activation paths implemented with keras.ops for TensorFlow, JAX, or Torch.
import omnibias.keras.activations.proximalModule contract & mathematical conventions
Proximal-class activations: huber, arctan, log1pu2.
Each one's K=2 bias-collapse limit is a classical proximal /
robust-statistics primitive. Mirrors
omnibias.torch.activations.proximal on keras.ops. arctan /
log1pu2 cover n in {0, 1, 2}; huber is closed form to all orders on
the almost-everywhere / regular-part convention (n = 2 indicator, n >= 3
zero), dropping the singular part at the +/-tau kinks.
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.
ARCTAN
omnibias.keras.activations.proximal.ARCTANSource ↗ARCTAN = register_activation(ActivationSpec(name='arctan', forward=_arctan_forward, derivative=_arctan_derivative, fastpath=_arctan_fastpath, integral=_arctan_integral, riccati_polynomial=None, noise_model='cauchy', operator_role='K=2 collapse -> 1/(1+z^2); Cauchy IRLS weight, natural for heavy-tailed regression residuals.', aliases=('atan',)))This exported constant is defined by the expression above. Its exact value and annotation come from the pinned source; use it with the module contract.
Read the implementation
ARCTAN = register_activation(
ActivationSpec(
name="arctan",
forward=_arctan_forward,
derivative=_arctan_derivative,
fastpath=_arctan_fastpath,
integral=_arctan_integral,
riccati_polynomial=None,
noise_model="cauchy",
operator_role=(
"K=2 collapse -> 1/(1+z^2); Cauchy IRLS weight, "
"natural for heavy-tailed regression residuals."
),
aliases=("atan",),
)
)HUBER
omnibias.keras.activations.proximal.HUBERSource ↗HUBER = register_activation(make_huber_spec(_DEFAULT_HUBER_TAU))This exported constant is defined by the expression above. Its exact value and annotation come from the pinned source; use it with the module contract.
Read the implementation
HUBER = register_activation(make_huber_spec(_DEFAULT_HUBER_TAU))LOG1PU2
omnibias.keras.activations.proximal.LOG1PU2Source ↗LOG1PU2 = register_activation(ActivationSpec(name='log1pu2', forward=_log1pu2_forward, derivative=_log1pu2_derivative, fastpath=_log1pu2_fastpath, integral=_log1pu2_integral, riccati_polynomial=None, noise_model='redescending_m', operator_role='K=2 collapse -> 2 z / (1 + z^2); redescending M-estimator (Black-Anandan family), down-weights large residuals to zero.', aliases=('logcosh_dual',)))This exported constant is defined by the expression above. Its exact value and annotation come from the pinned source; use it with the module contract.
Read the implementation
LOG1PU2 = register_activation(
ActivationSpec(
name="log1pu2",
forward=_log1pu2_forward,
derivative=_log1pu2_derivative,
fastpath=_log1pu2_fastpath,
integral=_log1pu2_integral,
riccati_polynomial=None,
noise_model="redescending_m",
operator_role=(
"K=2 collapse -> 2 z / (1 + z^2); redescending M-estimator "
"(Black-Anandan family), down-weights large residuals to zero."
),
aliases=("logcosh_dual",),
)
)make_huber_spec
omnibias.keras.activations.proximal.make_huber_specSource ↗make_huber_spec(tau: float=_DEFAULT_HUBER_TAU, *, register: bool=False) -> ActivationSpec[Any]Build a Huber ActivationSpec with custom threshold tau.
Parameters
| Name | Type & default | Contract |
|---|---|---|
taupositional-or-keyword | floatDefault: _DEFAULT_HUBER_TAU | See the operation contract and implementation below. |
registerkeyword-only | boolDefault: False | See the operation contract and implementation below. |
ActivationSpec[Any]Explicit validation & failure cases
- When
tau <= 0, raisesValueError(f'Huber tau must be > 0, got {tau}.').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Read the implementation
def make_huber_spec(
tau: float = _DEFAULT_HUBER_TAU, *, register: bool = False
) -> ActivationSpec[Any]:
"""Build a Huber :class:`ActivationSpec` with custom threshold ``tau``."""
if tau <= 0:
raise ValueError(f"Huber tau must be > 0, got {tau}.")
def fwd(z: Any) -> Any:
return _huber_forward(z, tau)
def deriv(z: Any) -> Any:
return _huber_derivative(z, tau)
def integ(z: Any) -> Any:
return _huber_integral(z, tau)
def fp(z: Any, n: int) -> Any:
return _huber_fastpath(z, n, tau)
name = "huber" if math.isclose(tau, _DEFAULT_HUBER_TAU) else f"huber_tau{tau:g}"
spec = ActivationSpec(
name=name,
forward=fwd,
derivative=deriv,
fastpath=fp,
integral=integ,
riccati_polynomial=None,
noise_model="laplace_smoothed",
operator_role=(
"K=2 collapse -> clip(z, -tau, tau); proximal of L1 / ISTA soft-shrink step for LASSO."
),
)
if register:
register_activation(spec)
return spec