Property bound API
PropertyBounds adapts affine/Boolean output specifications to auto_LiRPA and
is normally constructed by PropertyModelWrapper.
Calling it with a specification index and a batch of boxes returns lower
margins for the specification's top-level obligations. Composite formulas
retain their logical structure.
Boxes use the verification model's coordinates, with no implicit image
normalization. box_endpoints expands endpoints outward when casting their
stored dtype. See property semantics
and the certification API for complete reports rather
than interpreting a single bound as a whole-domain result.
Compute property satisfaction bounds while sharing the original network weights.
Affine comparisons are bounded through specification matrices. Boolean formulas are appended to the network as fixed satisfaction-margin graphs; property_bound='atomic' instead bounds and combines their affine leaves. Outer conjunctions are treated as separate requirements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
Verification network referenced by the specifications. |
required |
input_shape
|
tuple
|
Verification input shape without the batch dimension. |
required |
specs
|
Iterable[PropertySpec]
|
Specifications defining formulas and input boxes. |
required |
bound_opts
|
dict
|
auto_LiRPA options and optional property_bound='graph' or 'atomic'. |
None
|
Source code in CTRAIN/bound/properties.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
modules
property
Return the bounded network and composed formula graphs sharing its parameters.
__call__(spec_index, boxes, method='CROWN-IBP', *, relu_upper_retention=1.0)
Bound every top-level requirement over the supplied boxes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec_index
|
int
|
Index of the specification in the constructor's specs. |
required |
boxes
|
Sequence[Box]
|
Nonempty batch of regions in verification coordinates. |
required |
method
|
str
|
IBP, CROWN-IBP, CROWN or ALPHA-CROWN. |
'CROWN-IBP'
|
relu_upper_retention
|
float
|
Training-only IBP retention in (0, 1]. Values below one are unsound surrogates. |
1.0
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Lower margins of shape (number of boxes, number of requirements). Positive finite bounds establish satisfaction when retention is one. |
The computation uses evaluation-mode buffers while preserving caller modes and parameter gradient flags. Gradients through model weights remain available for training except during alpha-CROWN slope optimisation.
Source code in CTRAIN/bound/properties.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
point_margins(spec_index, output, *, boolean=False)
Evaluate each top-level requirement on a batch of network outputs.
With boolean=True, return exact pointwise satisfaction tests, including strict comparison ties. Otherwise return differentiable satisfaction margins.
Source code in CTRAIN/bound/properties.py
105 106 107 108 109 110 111 112 113 114 115 116 117 | |
sync_buffers()
Synchronise verification-graph buffers with the current network buffers.
Source code in CTRAIN/bound/properties.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
Convert stored box endpoints to the model device and dtype with outward rounding.
Source code in CTRAIN/bound/properties.py
14 15 16 17 18 19 20 21 22 23 | |