CC-Dist
Bases: CCIBPModelWrapper
Train a certified student using feature distillation from an adversarial teacher.
CC-Dist extends CC-IBP by aligning mixed adversarial and bounded student features with clean teacher features. The teacher must have the same feature width and class count as the student. A private frozen feature extractor supplies training targets and is excluded from the student's inference model. Both classifiers must expose a sequential forward graph ending in Linear.
The distillation weight defaults to 5 divided by the feature width; zero gives the CC-IBP control. Other training and evaluation options are inherited from CCIBPModelWrapper. See https://arxiv.org/abs/2602.02626.
Source code in CTRAIN/model_wrappers/certified/cc_dist_model_wrapper.py
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 79 80 81 82 83 84 85 86 87 88 89 90 | |
__init__(model, input_shape, eps, num_epochs, *, teacher, distillation_weight=None, **kwargs)
Configure student training and validate the frozen teacher feature extractor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
PyTorch model to train or evaluate. |
required |
input_shape
|
tuple[int, ...]
|
Shape of a model input, excluding the batch dimension unless supplied explicitly. |
required |
eps
|
float or Tensor
|
Target perturbation radius in raw input units, before loader normalisation. |
required |
num_epochs
|
int
|
Total training budget, including warm-up and ramp-up. |
required |
teacher
|
Module
|
Pretrained adversarial classifier with matching feature width and number of output classes. |
required |
distillation_weight
|
float
|
Feature-distillation weight. None uses 5 divided by the feature width. |
None
|
Source code in CTRAIN/model_wrappers/certified/cc_dist_model_wrapper.py
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 | |