pyiqa.models.lr_scheduler ========================= .. py:module:: pyiqa.models.lr_scheduler Module Contents --------------- .. py:class:: MultiStepRestartLR(optimizer, milestones, gamma=0.1, restarts=(0, ), restart_weights=(1, ), last_epoch=-1) Bases: :py:obj:`torch.optim.lr_scheduler._LRScheduler` MultiStep with restarts learning rate scheme. :param optimizer: Torch optimizer. :type optimizer: torch.nn.optimizer :param milestones: Iterations that will decrease learning rate. :type milestones: list :param gamma: Decrease ratio. Default: 0.1. :type gamma: float :param restarts: Restart iterations. Default: [0]. :type restarts: list :param restart_weights: Restart weights at each restart iteration. Default: [1]. :type restart_weights: list :param last_epoch: Used in _LRScheduler. Default: -1. :type last_epoch: int .. py:method:: get_lr() .. py:function:: get_position_from_periods(iteration, cumulative_period) Get the position from a period list. It will return the index of the right-closest number in the period list. For example, the cumulative_period = [100, 200, 300, 400], if iteration == 50, return 0; if iteration == 210, return 2; if iteration == 300, return 2. :param iteration: Current iteration. :type iteration: int :param cumulative_period: Cumulative period list. :type cumulative_period: list[int] :returns: The position of the right-closest number in the period list. :rtype: int .. py:class:: CosineAnnealingRestartLR(optimizer, periods, restart_weights=(1, ), eta_min=0, last_epoch=-1) Bases: :py:obj:`torch.optim.lr_scheduler._LRScheduler` Cosine annealing with restarts learning rate scheme. An example of config: periods = [10, 10, 10, 10] restart_weights = [1, 0.5, 0.5, 0.5] eta_min=1e-7 It has four cycles, each has 10 iterations. At 10th, 20th, 30th, the scheduler will restart with the weights in restart_weights. :param optimizer: Torch optimizer. :type optimizer: torch.nn.optimizer :param periods: Period for each cosine anneling cycle. :type periods: list :param restart_weights: Restart weights at each restart iteration. Default: [1]. :type restart_weights: list :param eta_min: The minimum lr. Default: 0. :type eta_min: float :param last_epoch: Used in _LRScheduler. Default: -1. :type last_epoch: int .. py:method:: get_lr()