credit.trainers.trainer_downscaling#
Attributes#
Classes#
Helper class that provides a standard way to create an ABC using |
Module Contents#
- credit.trainers.trainer_downscaling.logger#
- class credit.trainers.trainer_downscaling.Trainer(model: torch.nn.Module, rank: int)#
Bases:
credit.trainers.base_trainer.BaseTrainerHelper class that provides a standard way to create an ABC using inheritance.
- setup(conf)#
- train_one_epoch(epoch, conf, trainloader, optimizer, criterion, scaler, scheduler, metrics)#
Train the model for one epoch.
- Parameters:
epoch (int) – The current epoch number.
conf (Dict[str, Any]) – The configuration dictionary.
trainloader (torch.utils.data.DataLoader) – The training data loader.
optimizer (torch.optim.Optimizer) – The optimizer.
criterion (torch.nn.Module) – The loss function.
scaler (torch.cuda.amp.GradScaler) – The gradient scaler for mixed precision training.
scheduler (torch.optim.lr_scheduler.LRScheduler) – The learning rate scheduler.
metrics (Dict[str, Any]) – The metrics to track during training.
- Returns:
A dictionary containing the training results.
- Return type:
Dict[str, float]
- validate(epoch, conf, valid_loader, criterion, metrics)#
Validates the model on the validation dataset.
- Parameters:
epoch (int) – Current epoch number.
conf (dict) – Configuration dictionary containing validation settings.
valid_loader (DataLoader) – DataLoader for the validation dataset.
criterion (callable) – Loss function used for validation.
metrics (callable) – Function to compute metrics for evaluation.
- Returns:
Dictionary containing validation metrics and loss for the epoch.
- Return type:
dict