mononet.keras._kernels#
Private Keras 3 kernels for monotonic primitives (keras.ops only).
Module Contents#
Functions#
Apply the base activation by name. |
|
Concave reflection defined as |
|
Resolve and apply a gate token to a raw (unconstrained) parameter. |
|
Keras monotonic dense kernel (backend-agnostic via |
|
Keras dual-gated monotone residual kernel. |
API#
- mononet.keras._kernels.activation(name: str, h: Any) Any#
Apply the base activation by name.
- Parameters:
name – One of
relu,elu,selu,softplus.h – Input tensor (any keras-compatible array).
- Returns:
Activated tensor with the same shape as
h.- Raises:
ValueError – If
nameis not a supported activation.
- mononet.keras._kernels.concave_reflection(name: str, h: Any) Any#
Concave reflection defined as
-activation(-h).- Parameters:
name – Activation name passed to :func:
activation.h – Input tensor.
- Returns:
Negated activation of negated input, same shape as
h.
- mononet.keras._kernels.gate(token: str, raw: Any) Any#
Resolve and apply a gate token to a raw (unconstrained) parameter.
- Parameters:
token – One of
shifted_eluorscaled_elu.raw – Raw (unconstrained) gate parameter tensor.
- Returns:
Strictly-positive gate value, same shape as
raw.- Raises:
ValueError – If
tokenis not a supported gate token.
- mononet.keras._kernels.monotonic_dense(x: Any, weights: Any, bias: Any, mode: str, activation_name: str, convex_fraction: float = 0.5) Any#
Keras monotonic dense kernel (backend-agnostic via
keras.ops).- Parameters:
x – Input tensor of shape
(batch, in_features).weights – Weight matrix of shape
(in_features, units).bias – Bias vector of shape
(units,).mode – Either
switchorabsolute.activation_name – Base activation name (
relu,elu,selu,softplus).convex_fraction – Fraction of output units that use the convex activation; remainder use the concave reflection. Only used for
absolutemode.
- Returns:
Output tensor of shape
(batch, units).- Raises:
ValueError – If
modeis notswitchorabsolute.
- mononet.keras._kernels.monotonic_residual(x: Any, weights: Any, bias: Any, alpha: Any, beta: Any, *, mode: str, activation_name: str, convex_fraction: float = 0.5, alpha_gate: str = 'shifted_elu', beta_gate: str = 'scaled_elu', skip_weight: Any | None = None) Any#
Keras dual-gated monotone residual kernel.
- Parameters:
x – Input tensor of shape
(batch, in_features).weights – Weight matrix of shape
(in_features, units).bias – Bias vector of shape
(units,).alpha – Unconstrained skip-gate parameter (scalar or broadcastable).
beta – Unconstrained dense-gate parameter (scalar or broadcastable).
mode –
Either
switchorabsolute; forwarded to- func:
monotonic_dense.
activation_name –
Base activation name; forwarded to
- func:
monotonic_dense.
convex_fraction – Convex fraction for
absolutemode.alpha_gate – Gate token for the skip path (default
shifted_elu).beta_gate – Gate token for the dense path (default
scaled_elu).skip_weight – Optional projection log-weight matrix of shape
(in_features, units); when provided the skip path isx @ exp(skip_weight).
- Returns:
Output tensor of shape
(batch, units).