Property and task loss API
The property trainer combines a task loss with a property objective. See the property guide for margin semantics and strategy selection.
Property margin loss
property_loss accepts a batch of lower margins. Hinge loss sums deficits over
obligations, then averages regions unless reduction='none'. Cross-entropy uses
the padded-margin objective and ignores the hinge slack parameter. A training
loss is distinct from a whole-domain certificate.
Penalise deficits in property satisfaction margins.
The hinge loss sums max(0, margin - lower_margin) over requirements and vanishes once each target margin is reached. Cross-entropy instead uses a zero-padded margin vector. Reduction averages over boxes unless set to none.
Source code in CTRAIN/train/certified/losses/properties.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
Training strategies
The dispatcher receives explicit bound/model inputs and validated method
options. The legacy get_property_training_loss(wrapper, ...) entry point
delegates to it for compatibility.
Compute the selected training objective for a batch of property regions.
Each strategy reuses the shared satisfaction margins with its bound-based, adversarial, hybrid or regularised loss. The result is a scalar penalty for training; whole-region certification separately computes fresh sound bounds.
Source code in CTRAIN/train/certified/losses/property_methods.py
24 25 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 | |
Advisory preservation
For models whose lowest score selects an action, use fixed source-model
argmin labels sampled before repair. This empirical task loss does not
certify advisory preservation. The ONNX/VNNLIB notebook
shows the complete workflow.
Preserve source ACAS Xu advisories through cross-entropy on negated scores.
The lowest output score selects an advisory, so negating scores produces classification logits. Targets are integer source-model argmin advisories sampled before repair, with ties resolved by the first argmin. This empirical fidelity loss does not certify advisory preservation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scores
|
Tensor
|
Repaired model costs of shape (batch, actions). |
required |
target
|
Tensor
|
Source advisory indices of shape (batch,), with dtype torch.long. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Mean cross-entropy over the batch. |
Source code in CTRAIN/train/certified/losses/properties.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
Independent arithmetic heads
mnist_addition_cross_entropy expects [batch, 39] logits split into digit,
digit and sum heads of widths 10, 10 and 19, with [batch, 3] integer
labels [a, b, a+b]. It averages cross-entropy across the three heads.
See the arithmetic notebook.
Average cross-entropy for independently predicted digits and their sum.
Predictions concatenate heads of widths 10, 10 and 19; integer targets contain [a, b, a+b]. This task loss does not itself enforce arithmetic consistency.
Source code in CTRAIN/train/certified/losses/properties.py
25 26 27 28 29 30 31 32 33 34 35 36 | |