boundlab.zono.linearizers.Relu#
- class boundlab.zono.linearizers.Relu[source]#
Bases:
OpHandlerTriangle 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
Whether this handler applies to these operands (default: always).
Transform the operands; sub-operations go through
interp.<op>so the enclosing domain's handlers apply to them too.A copy of this handler that takes precedence over
otherwhen 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.
- override_handler(other)#
A copy of this handler that takes precedence over
otherwhen both are ready for the same call.