def __init__()

in kfac/python/keras/callbacks.py [0:0]


  def __init__(self,
               hyperparameter,
               init_value,
               final_value=None,
               decay_rate=None,
               num_decay_steps=None,
               **kwargs):
    """Construct a new ExponentialDecay Callback.

    You must specify exactly two of final_value, decay_rate, and
    num_decay_steps.


    Args:
      hyperparameter: String specifying the optimizer attribute to decay.
      init_value: Float specifying initial value of the attribute.
      final_value: Float specifying value of attribute at the end of the decay.
      decay_rate: Float specifying the decay rate of the decay.
      num_decay_steps: Integer, number of steps to decay the attribute.
      **kwargs: Keyword arguments for HyperparameterDecay. This includes
        num_delay_steps and verbose.
    """
    super(ExponentialDecay, self).__init__(hyperparameter, **kwargs)
    self._num_decay_steps = num_decay_steps

    # In theory, we could support more different combinations of final_value,
    # num_decay_steps, and decay_rate, but for the sake of clarity we will limit
    # this callback to the below combinations.
    if final_value and decay_rate and num_decay_steps:
      raise ValueError('You must specify exactly two of final_value, decay_rate'
                       ', and num_decay_steps.')
    if final_value and decay_rate:
      self._decay_func = lambda step: max(  # pylint: disable=g-long-lambda
          (init_value * (decay_rate ** step)), final_value)
    elif decay_rate and num_decay_steps:
      self._decay_func = lambda step: (init_value * decay_rate ** step)
    elif final_value and num_decay_steps:
      self._decay_func = lambda step: (  # pylint: disable=g-long-lambda
          init_value * (final_value / init_value) **
          (float(step) / num_decay_steps))
    else:
      raise ValueError('You must specify exactly two of final_value, decay_rate'
                       ', and num_decay_steps.')