clinicadl.optim.OptimizationConfig¶
- class clinicadl.optim.OptimizationConfig(**data: Any) None[source]¶
Config class to configure the optimization process.
- Parameters:
num_epochs (PositiveInt, default=10) – Number of epochs.
accumulation_steps (PositiveInt, default=1) – The number of loss computations for which gradients are accumulated before performing the weights update. This allows to virtually increase the size of the batch.
evaluation_interval (PositiveInt, default=1) – To perform evaluation on the validation every x epochs. For example, if
evaluation_interval=2, evaluation will be performed after epochs #2, #4, #6, #8, etc.clip_grad_norm (Optional[NonNegativeFloat], default=None) – To clip gradient norm. Give here the maximum norm accepted (a non-negative float). The norm is computed over the norms of the individual gradients of all parameters (see
torch.nn.utils.clip_grad_norm_()).grad_norm_type (float, default=2) – Indice p of the p-norm for gradient norm clipping. Can be any float.
clip_grad_value (Optional[NonNegativeFloat]) –
For individual gradients clipping (see
torch.nn.utils.clip_grad_value_()). Give here the maximum absolute value accepted (a non-negative float). Contrary to norm clipping, value clipping is performed on each gradient individually.Important
Gradient value clipping is performed before gradient norm clipping.
reset_model (ResetOption, default="all") – Whether to reset the neural network weights before a training phase. If
True, all the trainable parameters (i.e. withrequires_grad=True) will be randomly reset. Otherwise, the weights are not reset, so the weights initially passed when instantiating theTraineris always used as a starting point