sage.factory.schedulers
Filename : schedulers.py Description : Short description of the file
Created on 2026-03-06 16:29:32
__author__ = Narenraju Nagarajan __copyright__ = Copyright 2026, ProjectName __license__ = MIT Licence __version__ = 0.0.1 __maintainer__ = Narenraju Nagarajan __affiliation__ = N/A __email__ = N/A __status__ = [‘inProgress’, ‘Archived’, ‘inUsage’, ‘Debugging’]
GitHub Repository: NULL
Documentation: NULL
Classes
Unified adapter for PyTorch learning-rate schedulers with multiple |
Module Contents
- class ManageScheduler(scheduler, mode='batch')[source]
Unified adapter for PyTorch learning-rate schedulers with multiple step-trigger modes.
Different scheduler types require
step()to be called at different times (per batch, per epoch, or after a metric update). This wrapper standardises the interface by routingbatch_step()andepoch_step()calls to the underlying scheduler according to the configuredmode.- Parameters:
scheduler (torch.optim.lr_scheduler._LRScheduler) – The underlying scheduler instance.
mode (str) –
When to advance the scheduler:
"batch"— callscheduler.step()on every batch."fractional"— callscheduler.step(epoch + batch/total)for schedulers that accept a fractional epoch argument."epoch"— callscheduler.step()once per epoch (inepoch_step())."metric"— callscheduler.step(metric)once per epoch (e.g.torch.optim.lr_scheduler.ReduceLROnPlateau).
- batch_step(nepoch=None, nbatch=None, num_batches=None)[source]
Advance the scheduler at the end of a batch.
Only takes effect when
modeis"batch"or"fractional".
- epoch_step(metric=None)[source]
Advance the scheduler at the end of an epoch.
Only takes effect when
modeis"epoch"or"metric".- Parameters:
metric (float or None) – Validation metric value (required for
"metric"mode, e.g. validation loss passed toReduceLROnPlateau).