class_docstr: Cyclic LR: https://arxiv.org/abs/1811.11431
class_docstr_tok: ["Cyclic","LR",":","https",":","\/\/arxiv.org\/abs\/1811.11431"]
code: def __init__(self, opts, **kwargs) -> None:
      cycle_steps = getattr(opts, "scheduler.cyclic.steps", [25])
      if cycle_steps is not None and isinstance(cycle_steps, int):
          cycle_steps = [cycle_steps]
      gamma = getattr(opts, "scheduler.cyclic.gamma", 0.5)
      anneal_type = getattr(
          opts, "scheduler.cyclic.last_cycle_type", "linear"
      )
      min_lr = getattr(opts, "scheduler.cyclic.min_lr", 0.1)
      end_lr = getattr(opts, "scheduler.cyclic.last_cycle_end_lr", 1e-3)
      ep_per_cycle = getattr(
          opts, "scheduler.cyclic.epochs_per_cycle", 5
      )
      warmup_iterations = getattr(
          opts, "scheduler.warmup_iterations", 0
      )
      n_cycles = getattr(opts, "scheduler.cyclic.total_cycles", 10) - 1
      max_epochs = getattr(opts, "scheduler.max_epochs", 100)
  
      if anneal_type not in SUPPORTED_LAST_CYCLES:
          logger.error(
              "Supported anneal types for {} are: {}".format(
                  self.__class__.__name__, SUPPORTED_LAST_CYCLES
              )
          )
      if min_lr < end_lr:
          logger.error(
              "Min LR should be greater than end LR. Got: {} and {}".format(
                  min_lr, end_lr
              )
          )
  
      super(CyclicLRScheduler, self).__init__(opts=opts)
      self.min_lr = min_lr
      self.cycle_length = ep_per_cycle
      self.end_lr = end_lr
      self.max_lr = self.min_lr * self.cycle_length
      self.last_cycle_anneal_type = anneal_type
  
      if self.warmup_iterations > 0:
          self.warmup_step = (
              self.min_lr - self.warmup_init_lr
          ) / self.warmup_iterations
  
      self.n_cycles = n_cycles
  
      self.cyclic_epochs = self.cycle_length * self.n_cycles
      self.max_epochs = max_epochs
      self.last_cycle_epochs = self.max_epochs - self.cyclic_epochs
  
      assert (
          self.max_epochs == self.cyclic_epochs + self.last_cycle_epochs
      )
  
      self.steps = (
          [self.max_epochs] if cycle_steps is None else cycle_steps
      )
      self.gamma = gamma if cycle_steps is not None else 1
  
      self._lr_per_cycle()
      self.epochs_lr_stepped = []
  
file_path: ml-cvnets/optim/scheduler/cyclic.py
imports: import argparse
  import math
  import numpy
  from optim.scheduler import SCHEDULER_REGISTRY
  from optim.scheduler.base_scheduler import BaseLRScheduler
  from utils import logger
label_desc: Use image node_id 1 to create a new CyclicLRScheduler object from inherited base classes: BaseLRScheduler with example: obj = CyclicLRScheduler(opts)