boundlab.diff.zono3.linearizer_to_hander#

boundlab.diff.zono3.linearizer_to_hander(linearizer)[source]#

Register a differential lineariser for a non-linear activation.

The decorated function receives (xs, ys, ds) — three parallel lists of Expr, one entry per input to the nonlinearity — and returns a DiffZonoBounds.

For unary activations (relu, tanh, …) each list has length 1. For binary operations each list has length 2, with xs[i] / ys[i] / ds[i] being the i-th input’s x-network, y-network, and diff components respectively.

diff_bounds.input_weights[i] is the weight applied to ds[i]; diff_x_weights[i] / diff_y_weights[i] are the weights applied to xs[i] / ys[i]. diff_x_error / diff_y_error are applied to the same epsilon variables introduced for x_bounds / y_bounds, enabling exact diff tracking for cases where no fresh error is needed.

All inputs must be DiffExpr3 or DiffExpr2; if none are, the call falls back to the standard zonotope handler. DiffExpr2 inputs have their diff synthesised as x y.