ibp_r
IBP-R objective, equation (6) and optional masking in arXiv:2206.14772.
get_ibp_r_loss(hardened_model, original_model, ptb, data, target, kappa=1.0, rho=0.0002, regularisation_mask=False, pgd_steps=8, pgd_alpha=0.25, pgd_restarts=1, pgd_eps_factor=1.0, relu_upper_retention=1.0, data_min=None, data_max=None, eps=None, pgd_early_stopping=False, pgd_decay_factor=0.1, pgd_decay_checkpoints=(), clean_output=None)
Combine adversarial cross-entropy with unstable-ReLU relaxation penalties.
The clean-to-adversarial mixture is controlled by kappa. Fresh IBP intervals supply the regularisation areas, and optional masking selects correctly classified adversarial inputs. Returns the scalar loss and the predictions used for the adversarial component, or clean predictions at kappa=0.
kappa is the adversarial weight (0 for clean, 1 after mixing).
rho multiplies areas including their factor 1/2. Areas sum over
neurons and layers, then average over the entire batch, even with masking.
Both attack and IBP use the enlarged training box supplied in ptb.
pgd_eps_factor optionally scales only the attack; eps is the
scheduled radius before clipping. L1 regularisation belongs to the trainer.
Attacks run in eval mode; logits and bounds use the caller's module modes.
Retention below 1 is an optional unsound surrogate, absent from the paper.
kappa is the adversarial weight (0 for clean, 1 after mixing).
rho multiplies areas including their factor 1/2. Areas sum over
neurons and layers, then average over the entire batch, even with masking.
Both attack and IBP use the enlarged training box supplied in ptb.
pgd_eps_factor optionally scales only the attack; eps is the
scheduled radius before clipping. L1 regularisation belongs to the trainer.
Attacks run in eval mode; logits and bounds use the caller's module modes.
Retention below 1 is an optional unsound surrogate, absent from the paper.
Source code in CTRAIN/train/certified/losses/ibp_r.py
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 | |
relu_area(model, data)
Return each example's total unstable-ReLU relaxation area.
For fresh IBP preactivation intervals [l, u], each unstable neuron contributes (-l) * u / 2. Contributions are summed across neurons and layers.
Source code in CTRAIN/train/certified/losses/ibp_r.py
33 34 35 36 37 38 39 40 41 42 43 44 45 | |
validate_ibp_r_options(rho, pgd_steps, pgd_restarts, pgd_alpha, relu_upper_retention=1.0, pgd_eps_factor=1.0, pgd_decay_factor=0.1, pgd_decay_checkpoints=())
Validate the IBP-R penalty weight, attack schedule and bound-retention options.
Source code in CTRAIN/train/certified/losses/ibp_r.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |