biapy.engine.schedulers.warmup_cosine_decay
Learning rate scheduler with warmup and cosine decay for BiaPy.
This module provides the WarmUpCosineDecayScheduler class, which implements a learning rate schedule with a linear warmup phase followed by cosine decay, as commonly used in modern deep learning training pipelines.
- class biapy.engine.schedulers.warmup_cosine_decay.WarmUpCosineDecayScheduler(lr: float, min_lr: float, warmup_epochs: int, epochs: int)[source]
Bases:
objectLearning rate scheduler with linear warmup and cosine decay.
This scheduler increases the learning rate linearly for a specified number of warmup epochs, then decays it following a half-cycle cosine schedule down to a minimum learning rate.
- adjust_learning_rate(optimizer: Optimizer, epoch: float | int) float[source]
Decay the learning rate with half-cycle cosine after warmup.
- Parameters:
optimizer (Optimizer) – PyTorch optimizer whose learning rate will be adjusted.
epoch (float or int) – Current epoch (can be fractional for finer granularity).
- Returns:
lr – The adjusted learning rate.
- Return type:
float