NF Elementwise Bounds: Softplus and Safe Log #
NFBackend.safeLog is a clamped log surrogate $\log(\max(x,\varepsilon))$ with an unconditional
forward bound.
For smooth activations that use log (notably softplus and safeLog), we route the outer log
through safeLog at a known lower bound:
- $\operatorname{softplus}(x)=\log(1+\exp x)$ and $1+\exp x\ge 1$, so $\operatorname{softplus}(x)=\operatorname{safeLog}(1,1+\exp x)$;
- $\operatorname{safeLog}(x)=\log(\operatorname{softplus}(x)+\varepsilon)$ and $\operatorname{softplus}(x)+\varepsilon\ge\varepsilon$, so $\operatorname{safeLog}(x) =\operatorname{safeLog}(\varepsilon,\operatorname{softplus}(x)+\varepsilon)$.
This avoids needing a separate log approximation lemma while remaining extensionally equal on
ℝ for the intended arguments.
Half-ULP rounding budget at the scalar value 1, used in the softplus helper bounds.
Instances For
Rounded representation of the scalar constant 1 at the NF backend.
Instances For
Rounded representation of exp a at the NF backend.
Instances For
Rounded surrogate for the inner 1 + exp a term appearing in softplus.
Instances For
Forward-error envelope for the rounded 1 + exp a subexpression used by softplus.
Instances For
Unconditional scalar forward-error bound for softplus, via the safeLog factorization.
Instances For
softplus implemented by safeLog 1 (1 + exp x) at the NF backend.
Instances For
softplus_spec_eq_log_one_add_exp lives in Proofs.Gradients.Activation, which this file imports.
This namespace is nested inside Proofs, so the uses below resolve to it without qualification and
without an open. The private copy that used to sit here proved the same statement.
Forward approximation bound for softplus in NF.
We treat softplus(x) = log(1 + exp x) as safeLog 1 (1 + exp x) (since 1 + exp x ≥ 1) and then
compose the scalar bounds for exp, +, and safeLog.
Per-entry bound tensor for softplusR.
This is the elementwise lifting of softplusBoundScalar, used with linfNorm in
approxTensor_softplus_spec.
Instances For
approxTensor bound for softplus lifted to arbitrary tensor shapes.
This is the tensor-level wrapper around approx_softplus_nf, built via
approxTensor_map_spec_of_scalar_bound.
Runtime implementation of safeLog as a single rounded primitive.
Instances For
Forward approximation bound for the smooth safeLog activation in NF.
safeLog is defined as log(softplus(x) + ε), which is globally well-defined for ε > 0. The
proof combines:
- one rounding step for
safeLogR(defined asNF.ofReal (safe_log_spec ...)); - a
(1/ε)Lipschitz bound for the spec function (via mean value theorem + derivative bound).
Per-entry bound tensor for safeLog.
This is the elementwise lifting of approx_safe_log_nf's bound.
Instances For
approxTensor bound for safeLog lifted to arbitrary tensor shapes.
This is the tensor-level wrapper around approx_safe_log_nf, built via
approxTensor_map_spec_of_scalar_bound.