class_docstr: Set hyperparameters by a predefined epoch-based schedule.
docstr: Args:
      param: same as in :class:`HyperParamSetter`.
      schedule (list): with the format ``[(epoch1, val1), (epoch2, val2), (epoch3, val3)]``.
          Each ``(ep, val)`` pair means to set the param
          to "val" **after** the completion of epoch `ep`.
          If ep == 0, the value will be set before the first epoch
          (because by default the first is epoch 1).
          The epoch numbers have to be increasing.
      interp (str or None): Either None or 'linear'.
          If None, the parameter will only be set when the specific epoch or steps
          is reached exactly. If 'linear', perform linear interpolation (but no extrapolation)
          every time this callback is triggered.
      step_based (bool): interpret ``schedule`` as (step, value) instead
          of (epoch, value).
      set_at_beginning (bool): at the start of training, the current value
          may be different from the expected value according to the
          schedule.
          If this option is True, set the value anyway even though the current
          epoch/step is not at the scheduled time.
          If False, the value will only be set according to the
          schedule, i.e. it will only be set if the current epoch/step
          is at the scheduled time.
  
  Example:
      .. code-block:: python
  
          ScheduledHyperParamSetter('learning_rate',
                                    [(30, 1e-2), (60, 1e-3), (85, 1e-4), (95, 1e-5)]),
docstr_tok: ["Args",":","param",":","same","as","in",":","class",":","`","HyperParamSetter","`",".","schedule","(","list",")",":","with","the","format","``","[","(","epoch1",",","val1",")",",","(","epoch2",",","val2",")",",","(","epoch3",",","val3",")","]","``",".","Each","``","(","ep",",","val",")","``","pair","means","to","set","the","param","to","``","val","''","*","*","after","*","*","the","completion","of","epoch","`","ep","`",".","If","ep","==","0",",","the","value","will","be","set","before","the","first","epoch","(","because","by","default","the","first","is","epoch","1",")",".","The","epoch","numbers","have","to","be","increasing",".","interp","(","str","or","None",")",":","Either","None","or","'linear","'",".","If","None",",","the","parameter","will","only","be","set","when","the","specific","epoch","or","steps","is","reached","exactly",".","If","'linear","'",",","perform","linear","interpolation","(","but","no","extrapolation",")","every","time","this","callback","is","triggered",".","step_based","(","bool",")",":","interpret","``","schedule","``","as","(","step",",","value",")","instead","of","(","epoch",",","value",")",".","set_at_beginning","(","bool",")",":","at","the","start","of","training",",","the","current","value","may","be","different","from","the","expected","value","according","to","the","schedule",".","If","this","option","is","True",",","set","the","value","anyway","even","though","the","current","epoch\/step","is","not","at","the","scheduled","time",".","If","False",",","the","value","will","only","be","set","according","to","the","schedule",",","i.e",".","it","will","only","be","set","if","the","current","epoch\/step","is","at","the","scheduled","time",".","Example",":","..","code-block",":",":","python","ScheduledHyperParamSetter","(","'learning_rate","'",",","[","(","30",",","1e-2",")",",","(","60",",","1e-3",")",",","(","85",",","1e-4",")",",","(","95",",","1e-5",")","]",")",","]
code: def __init__(
      self,
      param,
      schedule,
      interp=None,
      step_based=False,
      set_at_beginning=True,
  ):
      """
      Args:
          param: same as in :class:`HyperParamSetter`.
          schedule (list): with the format ``[(epoch1, val1), (epoch2, val2), (epoch3, val3)]``.
              Each ``(ep, val)`` pair means to set the param
              to "val" **after** the completion of epoch `ep`.
              If ep == 0, the value will be set before the first epoch
              (because by default the first is epoch 1).
              The epoch numbers have to be increasing.
          interp (str or None): Either None or 'linear'.
              If None, the parameter will only be set when the specific epoch or steps
              is reached exactly. If 'linear', perform linear interpolation (but no extrapolation)
              every time this callback is triggered.
          step_based (bool): interpret ``schedule`` as (step, value) instead
              of (epoch, value).
          set_at_beginning (bool): at the start of training, the current value
              may be different from the expected value according to the
              schedule.
              If this option is True, set the value anyway even though the current
              epoch/step is not at the scheduled time.
              If False, the value will only be set according to the
              schedule, i.e. it will only be set if the current epoch/step
              is at the scheduled time.
  
      Example:
          .. code-block:: python
  
              ScheduledHyperParamSetter('learning_rate',
                                        [(30, 1e-2), (60, 1e-3), (85, 1e-4), (95, 1e-5)]),
      """
      schedule = [(int(a), float(b)) for a, b in schedule]
      self.schedule = sorted(schedule, key=operator.itemgetter(0))
      if interp is not None:
          assert interp == "linear"
      self.interp = interp
      self._step = step_based
      self._set_at_beginning = set_at_beginning
      super(ScheduledHyperParamSetter, self).__init__(param)
  
imports: import operator
  import os
  import numpy
  from abc import ABCMeta, abstractmethod
  from collections import deque
  import six
  from ..compat import tfv1
  from ..tfutils.common import get_op_tensor_name
  from ..utils import logger
  from .base import Callback
label_desc: Use image node_id 1 to create a new ScheduledHyperParamSetter object from inherited base classes: HyperParamSetter with example: obj = ScheduledHyperParamSetter(param, schedule, interp, step_based, set_at_beginning)