boundlab.zono.linearizers.Tanh#

class boundlab.zono.linearizers.Tanh[source]#

Bases: OpHandler

Minimal-derivative enclosure of \(\tanh\) (DeepZ-style).

The slope \(\lambda = \min(1 - \tanh^2 l,\; 1 - \tanh^2 u)\) never exceeds the true derivative anywhere in \([l, u]\) (\(\tanh'\) is unimodal), so the residual \(\tanh(x) - \lambda x\) is monotone and attains its extremes at the endpoints; \(\mu\) and \(\beta\) center that endpoint range.

Methods

__init__

apply_bound

condition

Whether this handler applies to these operands (default: always).

handle

Transform the operands; sub-operations go through interp.<op> so the enclosing domain's handlers apply to them too.

override_handler

A copy of this handler that takes precedence over other when both are ready for the same call.

__call__(l, u, x=None)#

Call self as a function.

__init__(op='tanh', apply_bound=<function linearizer_fn.<locals>.decorator.<locals>.LinearizerHandler.<lambda>>)#
apply_bound(x)#
condition(x, **kwargs)#

Whether this handler applies to these operands (default: always).

handle(interp, x, **kwargs)#

Transform the operands; sub-operations go through interp.<op> so the enclosing domain’s handlers apply to them too.

op: str = 'tanh'#
override_handler(other)#

A copy of this handler that takes precedence over other when both are ready for the same call.

overrides: list[type[OpHandler]] = []#