boundlab.diff.zono3.interpret#
- boundlab.diff.zono3.interpret = <boundlab.interp.Interpreter object>#
Differential-verification interpreter.
Feed it a
DiffExpr3(x, y, d)where x and y are the two networks’ zonotope expressions and d over-approximates their difference, or a plainExprfor standard zonotope interpretation.Examples
Differential mode (
DiffExpr3input):>>> import torch >>> from torch import nn >>> import boundlab.expr as expr >>> from boundlab.diff.expr import DiffExpr3 >>> from boundlab.diff.zono3 import interpret >>> model = nn.Linear(4, 3) >>> op = interpret(model) >>> x = expr.ConstVal(torch.randn(4)) + expr.LpEpsilon([4]) >>> y = expr.ConstVal(torch.randn(4)) + expr.LpEpsilon([4]) >>> out = op(DiffExpr3(x, y, x - y)) >>> out.diff.ub().shape torch.Size([3])
Fallback mode (plain
Expr) matches standard zonotope interpretation:>>> z = expr.ConstVal(torch.randn(4)) + expr.LpEpsilon([4]) >>> z_out = op(z) >>> z_out.ub().shape torch.Size([3])