boundlab.poly#
Polytope-Based Abstract Interpretation for Neural Networks.
This module provides CROWN-style abstract interpretation using linear polytope relaxations of nonlinear activations. Each neuron is bounded by a pair of linear envelopes:
The central PolyBoundGate expression represents an abstract
function with fixed \(\pm 1\) offsets; general CROWN-style bounds
are wrapped by rescaling around their midpoint.
Examples
>>> import torch
>>> from torch import nn
>>> import boundlab.expr as expr
>>> import boundlab.poly as poly
>>> model = nn.Sequential(nn.Linear(4, 5), nn.ReLU(), nn.Linear(5, 3))
>>> op = poly.interpret(model)
>>> x = expr.ConstVal(torch.zeros(4)) + expr.LpEpsilon([4])
>>> y = op(x)
>>> y.ub().shape
torch.Size([3])
Module Attributes
Polytope-based interpreter. |
Functions
CROWN relaxation of ReLU. |
|
CROWN relaxation of \(\exp\). |
|
CROWN relaxation of \(1/x\) on a strictly positive domain. |
|
CROWN relaxation of \(\tanh\). |
|
CROWN relaxation of \(x^2\). |
|
Polytope softmax transformer via the DeepT decomposition. |
|
Dispatcher implementation for |
|
Dispatcher implementation for element-wise multiplication. |
Classes
Abstract gate bounded pointwise by a pair of linear polytopes on its child. |
|
CROWN-style linear relaxation bounds for a unary nonlinearity. |