16 @brief Configuration for Minimum Output Difference algorithm.
18 @details Defines parameters controlling whether and how Mod is applied during quantization, including layer-level inclusion/exclusion lists.
28 "lr_weight_scale": 0.0,
34 "post_processing":
"",
39 "kl_temperature": 1.0,
46 [[12, 16], [19, 36], [40, 28]],
47 [[36, 75], [76, 55], [72, 146]],
48 [[142, 110], [192, 243], [459, 401]],
55 "custom_loss_jit_path":
"",
56 "mod_after_layer_name":
"",
62 "warmup_epochs":
"warmupEpochs",
63 "lr_min_ratio":
"lrMinRatio",
64 "lr_act_scale":
"actScaleLR",
65 "lr_zeropoint":
"zeropointLR",
66 "lr_weight_scale":
"weightScaleLR",
67 "lr_weight":
"weightLR",
69 "batch_size":
"batchSize",
71 "post_processing":
"post",
72 "box_conf_thres":
"boxConfThres",
73 "box_iou_thres":
"boxIoUThres",
74 "loss_type":
"lossType",
75 "use_outputs":
"useOutputs",
76 "kl_temperature":
"KLTemperature",
77 "recon_prob":
"reconProb",
78 "recon_coeff":
"reconCoeff",
79 "lambda_0":
"lambda_0",
80 "lambda_1":
"lambda_1",
81 "lambda_2":
"lambda_2",
82 "use_xyxy":
"useXYXY",
83 "save_dir":
"saveDir",
85 "custom_loss_jit_path":
"customLossJITPath",
86 "mod_after_layer_name":
"modAfterLayerName",
91 "warmup_epochs": [0,
None],
92 "lr_min_ratio": [0,
None],
93 "lr_act_scale": [0,
None],
94 "lr_zeropoint": [0,
None],
95 "lr_weight_scale": [0,
None],
96 "lr_weight": [0,
None],
98 "batch_size": [0,
None],
100 "box_conf_thres": [0,
None],
101 "box_iou_thres": [0,
None],
102 "kl_temperature": [0,
None],
103 "recon_prob": [0, 1],
104 "recon_coeff": [0,
None],
105 "lambda_0": [0,
None],
106 "lambda_1": [0,
None],
107 "lambda_2": [0,
None],
117 lr_act_scale: numbers.Number,
118 lr_zeropoint: numbers.Number,
119 lr_weight_scale: numbers.Number,
120 lr_weight: numbers.Number,
121 lr_bias: numbers.Number,
122 lr_min_ratio: numbers.Number,
124 q_drop: numbers.Number,
125 post_processing: str,
126 box_conf_thres: numbers.Number,
127 box_iou_thres: numbers.Number,
130 kl_temperature: numbers.Number,
131 recon_prob: numbers.Number,
132 recon_coeff: numbers.Number,
133 lambda_0: numbers.Number,
134 lambda_1: numbers.Number,
135 lambda_2: numbers.Number,
140 apply_layers: List[str],
141 exclude_layers: List[str],
142 custom_loss_jit_path: str,
143 mod_after_layer_name: str,
144 optional: bool = optional,
147 @brief Initialize the ModConfig.
148 @param apply bool. Whether to apply MOD.
149 @param epochs int. Number of training epochs.
150 @param warmup_epochs int. Number of warmup epochs.
151 @param lr_act_scale float. Learning rate for activation scale.
152 @param lr_zeropoint float. Learning rate for zeropoint.
153 @param lr_weight_scale float. Learning rate for weight scale.
154 @param lr_weight float. Learning rate for weight.
155 @param lr_bias float. Learning rate for bias.
156 @param lr_min_ratio float. Minimum learning rate ratio for scheduler.
157 @param batch_size int. Batch size for training.
158 @param q_drop float. QDrop ratio.
159 @param post_processing str. Post-processing function.
160 @param box_conf_thres float. Box confidence threshold for NMS.
161 @param box_iou_thres float. Box IoU threshold for NMS.
162 @param loss_type str. Loss function type.
163 @param use_outputs bool. Compare only intermediate layers.
164 @param kl_temperature float. Temperature for KL divergence loss.
165 @param recon_prob float. Sampling probability for intermediate layers.
166 @param recon_coeff float. Coefficient for intermediate layer loss.
167 @param lambda_0 float. First coefficient for AnchorlessDetection loss.
168 @param lambda_1 float. Second coefficient for AnchorlessDetection loss.
169 @param lambda_2 float. Third coefficient for AnchorlessDetection loss.
170 @param anchors List. Anchor boxes configuration.
171 @param use_xyxy bool. Use XYXY format.
172 @param save_dir str. Directory to save results.
173 @param seed int. Random seed.
174 @param apply_layers List[str]. Layers to apply MOD.
175 @param exclude_layers List[str]. Layers to exclude from MOD.
176 @param custom_loss_jit_path str. Path to custom loss JIT file.
177 @param mod_after_layer_name str. Layer name to apply MOD after.
178 @param optional bool. Indicates whether this config is optional. Use the default value defined as a class variable.
212 except_list=[
"optional",
"anchors",
"apply_layers",
"exclude_layers"]
216 def default_config(cls):
221 """Create ModConfig from dictionary (JSON structure)"""
224 if "apply" in config_dict:
225 params[
"apply"] = config_dict[
"apply"]
227 if "attributes" in config_dict:
228 attributes = config_dict[
"attributes"]
230 if "epochs" in attributes:
231 params[
"epochs"] = attributes[
"epochs"]
232 if "warmupEpochs" in attributes:
233 params[
"warmup_epochs"] = attributes[
"warmupEpochs"]
234 if "lrMinRatio" in attributes:
235 params[
"lr_min_ratio"] = attributes[
"lrMinRatio"]
236 if "anchors" in attributes:
237 params[
"anchors"] = attributes[
"anchors"]
238 if "useXYXY" in attributes:
239 params[
"use_xyxy"] = attributes[
"useXYXY"]
240 if "saveDir" in attributes:
241 params[
"save_dir"] = attributes[
"saveDir"]
242 if "seed" in attributes:
243 params[
"seed"] = attributes[
"seed"]
244 if "applyLayers" in attributes:
245 params[
"apply_layers"] = attributes[
"applyLayers"]
246 if "excludeLayers" in attributes:
247 params[
"exclude_layers"] = attributes[
"excludeLayers"]
248 if "modAfterLayerName" in attributes:
249 params[
"mod_after_layer_name"] = attributes[
"modAfterLayerName"]
251 if "learningRates" in attributes:
252 learning_rates = attributes[
"learningRates"]
253 if "actScale" in learning_rates:
254 params[
"lr_act_scale"] = learning_rates[
"actScale"]
255 if "zeropoint" in learning_rates:
256 params[
"lr_zeropoint"] = learning_rates[
"zeropoint"]
257 if "weightScale" in learning_rates:
258 params[
"lr_weight_scale"] = learning_rates[
"weightScale"]
259 if "weight" in learning_rates:
260 params[
"lr_weight"] = learning_rates[
"weight"]
261 if "bias" in learning_rates:
262 params[
"lr_bias"] = learning_rates[
"bias"]
264 if "training" in attributes:
265 training = attributes[
"training"]
266 if "batchSize" in training:
267 params[
"batch_size"] = training[
"batchSize"]
268 if "qDrop" in training:
269 params[
"q_drop"] = training[
"qDrop"]
271 if "postProcessing" in attributes:
272 post_processing = attributes[
"postProcessing"]
273 if "post" in post_processing:
274 params[
"post_processing"] = post_processing[
"post"]
275 if "boxConfThres" in post_processing:
276 params[
"box_conf_thres"] = post_processing[
"boxConfThres"]
277 if "boxIoUThres" in post_processing:
278 params[
"box_iou_thres"] = post_processing[
"boxIoUThres"]
280 if "loss" in attributes:
281 loss = attributes[
"loss"]
283 params[
"loss_type"] = loss[
"type"]
284 if "useOutputs" in loss:
285 params[
"use_outputs"] = loss[
"useOutputs"]
286 if "KLTemperature" in loss:
287 params[
"kl_temperature"] = loss[
"KLTemperature"]
288 if "reconProb" in loss:
289 params[
"recon_prob"] = loss[
"reconProb"]
290 if "reconCoeff" in loss:
291 params[
"recon_coeff"] = loss[
"reconCoeff"]
292 if "lambda_0" in loss:
293 params[
"lambda_0"] = loss[
"lambda_0"]
294 if "lambda_1" in loss:
295 params[
"lambda_1"] = loss[
"lambda_1"]
296 if "lambda_2" in loss:
297 params[
"lambda_2"] = loss[
"lambda_2"]
299 if "customLossJITPath" in loss:
300 params[
"custom_loss_jit_path"] = loss[
"customLossJITPath"]
__init__(self, bool apply, int epochs, int warmup_epochs, numbers.Number lr_act_scale, numbers.Number lr_zeropoint, numbers.Number lr_weight_scale, numbers.Number lr_weight, numbers.Number lr_bias, numbers.Number lr_min_ratio, int batch_size, numbers.Number q_drop, str post_processing, numbers.Number box_conf_thres, numbers.Number box_iou_thres, str loss_type, bool use_outputs, numbers.Number kl_temperature, numbers.Number recon_prob, numbers.Number recon_coeff, numbers.Number lambda_0, numbers.Number lambda_1, numbers.Number lambda_2, List anchors, bool use_xyxy, str save_dir, int seed, List[str] apply_layers, List[str] exclude_layers, str custom_loss_jit_path, str mod_after_layer_name, bool optional=optional)
Initialize the ModConfig.