Learn Before
Code
Factor Learning Rate Scheduler Implementation
A factor learning rate scheduler applies multiplicative decay to the learning rate while enforcing a lower-bound constraint, mathematically expressed as . This can be implemented from scratch in Python by defining a custom FactorScheduler class. The __call__ method updates the learning rate at each step by multiplying the base learning rate by a specified decay factor, ensuring the rate does not fall below the minimum threshold (stop_factor_lr). Alternatively, deep learning frameworks like MXNet provide built-in solutions such as lr_scheduler.FactorScheduler, which offer additional hyperparameters like warmup periods and maximum update limits.
class FactorScheduler: def __init__(self, factor=1, stop_factor_lr=1e-7, base_lr=0.1): self.factor = factor self.stop_factor_lr = stop_factor_lr self.base_lr = base_lr def __call__(self, num_update): self.base_lr = max(self.stop_factor_lr, self.base_lr * self.factor) return self.base_lr
0
1
Updated 2026-05-18
Tags
D2L
Dive into Deep Learning @ D2L