convex_combinations
get_mtl_ibp_loss(hardened_model, original_model, ptb, data, target, n_classes, criterion, alpha, return_bounds=False, return_stats=False, restarts=1, step_size=0.2, n_steps=200, pgd_ptb=None, early_stopping=False, decay_checkpoints=(), decay_factor=0.1, device='cuda')
Computes the MTL-IBP loss.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hardened_model
|
BoundedModule
|
The bounded model to be trained. |
required |
original_model
|
Module
|
The original model. |
required |
ptb
|
PerturbationLpNorm
|
The perturbation applied to the input data. |
required |
data
|
Tensor
|
Input data. |
required |
target
|
Tensor
|
Target labels. |
required |
n_classes
|
int
|
Number of classes. |
required |
criterion
|
callable
|
Loss function. |
required |
alpha
|
float
|
Weighting factor between robust loss and adversarial loss. |
required |
return_bounds
|
bool
|
If True, returns bounds. Default is False. |
False
|
return_stats
|
bool
|
If True, returns robustness and adversarial error statistics. Default is False. |
False
|
restarts
|
int
|
Number of restarts for PGD attack. Default is 1. |
1
|
step_size
|
float
|
Step size for PGD attack. Default is 0.2. |
0.2
|
n_steps
|
int
|
Number of steps for PGD attack. Default is 200. |
200
|
pgd_ptb
|
object
|
PGD perturbation object. Default is None. |
None
|
early_stopping
|
bool
|
If True, stops early during PGD attack. Default is False. |
False
|
decay_checkpoints
|
tuple
|
Checkpoints for decay during PGD attack. Default is (). |
()
|
decay_factor
|
float
|
Decay factor for PGD attack. Default is 0.1. |
0.1
|
device
|
str
|
Device to run the computations on. Default is 'cuda'. |
'cuda'
|
Returns:
Type | Description |
---|---|
tuple
|
A tuple containing the loss, and optionally certified and adversarial error statistics. |
Source code in CTRAIN/train/certified/losses/convex_combinations.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 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 |
|