boundlab.zono.linearizers.Relu#

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

Bases: OpHandler

Triangle relaxation of ReLU.

The chord slope \(\lambda = (\mathrm{relu}(u) - \mathrm{relu}(l)) / (u - l)\) makes the residual \(\mathrm{relu}(x) - \lambda x\) range over \([0,\; \mathrm{relu}(u) - \lambda u]\) on a crossing interval (extremes at the kink and at the endpoints), so centering gives \(\mu = \beta = (\mathrm{relu}(u) - \lambda u)/2\). On stable intervals \(\lambda \in \{0, 1\}\) and \(\beta = 0\) — exact. This slope choice minimizes \(\beta\) among all sound affine enclosures (the DeepZ/triangle optimum).

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='relu', 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 = 'relu'#
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]] = []#