Set-based zonotope propagation API
CTRAIN.bound.set_based_zono contains the specialized representation and
auto_LiRPA adapters used by set-based training. It retains centers, correlated
generators and independent error radii for the training objective; it is not
a general zonotope library.
See representation and operators for supported semantics and local LiRPA adapters.
Represent a correlated input or output enclosure for set-based training.
The represented points are c + sum_q G[:, q] * xi_q + r * eta, where each xi_q and each coordinate of eta lie in [-1, 1]. Shared generator coefficients preserve coordinate correlations, while r describes independent error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
Tensor
|
Centre of shape (batch, ...). |
required |
G
|
Tensor
|
Correlated generators of shape (batch, Q, ...). |
required |
r
|
Tensor
|
Nonnegative independent radii with the same shape as c. |
required |
Source code in CTRAIN/bound/set_based_zono.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
bounds()
Return coordinatewise lower and upper endpoints enclosing the zonotope.
Source code in CTRAIN/bound/set_based_zono.py
41 42 43 44 | |
Propagate a correlated enclosure through supported auto_LiRPA operators.
The returned Zonotope retains its centre, generators and independent error radii with an autograd graph for set-based training. Same-slope ReLU relaxations preserve shared generator coefficients. Nonlinear errors either remain independent intervals or become additional generators.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
Supported sequential network. |
required |
zonotope
|
Zonotope
|
Input enclosure in model coordinates. |
required |
error_propagation
|
str
|
'interval' or 'generators'. |
'interval'
|
bn_statistics
|
dict
|
Differentiable clean means and variances indexed by BatchNorm layer. Otherwise evaluation uses running statistics. |
None
|
layers
|
list
|
Previously validated sequential layers. |
None
|
Returns:
| Type | Description |
|---|---|
Zonotope
|
Propagated output enclosure, retaining parameter gradients. |
Source code in CTRAIN/bound/set_based_zono.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
Input boxes and output margins
box_zonotope builds this representation from finite, ordered, batched lower
and upper endpoints, with one diagonal generator per input coordinate.
zonotope_margins returns lower true-class-minus-competitor margins, retaining
generator correlations. Its true-class entry is inf and can be ignored when
checking whether every competing-class margin is positive.
For ordinary full-box classification certification, use the
shared evaluation API with method="FORWARD".
Represent a finite, ordered input box using one generator per coordinate.
Returns a Zonotope centred at (lower + upper) / 2 with independent half-width generators and zero additional error radii.
Source code in CTRAIN/bound/set_based_zono.py
90 91 92 93 94 95 96 97 98 99 | |
Compute lower classification margins while retaining generator correlations.
Shared generator contributions may cancel when subtracting competing logits; independent error radii are added. Returns one column per class, with the true-class column set to infinity.
Source code in CTRAIN/bound/set_based_zono.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |