medkit.training.trainer_config
medkit.training.trainer_config#
Classes:
|
Trainer configuration |
- class TrainerConfig(output_dir, learning_rate=1e-05, nb_training_epochs=3, dataloader_nb_workers=0, batch_size=1, seed=None, gradient_accumulation_steps=1, do_metrics_in_training=False, metric_to_track_lr='loss', checkpoint_period=1, checkpoint_metric='loss', minimize_checkpoint_metric=True)[source]#
Trainer configuration
- Parameters
output_dir (str) – The output directory where the checkpoint will be saved.
learning_rate (float) – The initial learning rate.
nb_training_epochs (int) – Total number of training/evaluation epochs to do.
dataloader_nb_workers (int) – Number of subprocess for the data loading. The default value is 0, the data will be loaded in the main process. If this config is for a HuggingFace model, do not change this value.
batch_size (int) – Number of samples per batch to load.
seed (Optional[int]) – Random seed to use with PyTorch and numpy. It should be set to ensure reproducibility between experiments.
gradient_accumulation_steps (int) – Number of steps to accumulate gradient before performing an optimization step.
do_metrics_in_training (bool) – By default, only the custom metrics are computed using eval_data. If set to True, the custom metrics are computed also using training_data.
metric_to_track_lr (str) – Name of the eval metric to be tracked for updating the learning rate. By default, eval loss is tracked.
checkpoint_period (int) – How often, in number of epochs, should we save a checkpoint. Use 0 to only save last checkpoint.
checkpoint_metric (str) – Name of the eval metric to be tracked for selecting the best checkpoint. By default, eval loss is tracked.
minimize_checkpoint_metric (bool) – If True, the checkpoint with the lowest metric value will be selected as best, otherwise the checkpoint with the highest metric value.