class_docstr: Decaying hyperparameter (specification key: `decaying`, `linear`, `exponential`, `polynomial`,
  `inverse_time`, `cosine`, `cosine_restarts`, `linear_cosine`, `linear_cosine_noisy`).
  
  Args:
      decay ("linear" | "exponential" | "polynomial" | "inverse_time" | "cosine" | "cosine_restarts" | "linear_cosine" | "linear_cosine_noisy"):
          Decay type, see also
          `TensorFlow docs <https://www.tensorflow.org/api_docs/python/tf/train>`__
          (<span style="color:#C00000"><b>required</b></span>).
      unit ("timesteps" | "episodes" | "updates"): Unit of decay schedule
          (<span style="color:#C00000"><b>required</b></span>).
      num_steps (int): Number of decay steps
          (<span style="color:#C00000"><b>required</b></span>).
      initial_value (float | int): Initial value
          (<span style="color:#C00000"><b>required</b></span>).
      increasing (bool): Whether to subtract the decayed value from 1.0
          (<span style="color:#00C000"><b>default</b></span>: false).
      inverse (bool): Whether to take the inverse of the decayed value
          (<span style="color:#00C000"><b>default</b></span>: false).
      scale (float): Scaling factor for (inverse) decayed value
          (<span style="color:#00C000"><b>default</b></span>: 1.0).
      kwargs: Additional arguments depend on decay mechanism.<br>
          Linear decay:
          <ul>
          <li><b>final_value</b> (<i>float | int</i>) &ndash; Final value
          (<span style="color:#C00000"><b>required</b></span>).</li>
          </ul>
          Exponential decay:
          <ul>
          <li><b>decay_rate</b> (<i>float</i>) &ndash; Decay rate
          (<span style="color:#C00000"><b>required</b></span>).</li>
          <li><b>staircase</b> (<i>bool</i>) &ndash; Whether to apply decay in a discrete
          staircase, as opposed to continuous, fashion.
          (<span style="color:#00C000"><b>default</b></span>: false).</li>
          </ul>
          Polynomial decay:
          <ul>
          <li><b>final_value</b> (<i>float | int</i>) &ndash; Final value
          (<span style="color:#C00000"><b>required</b></span>).</li>
          <li><b>power</b> (<i>float | int</i>) &ndash; Power of polynomial
          (<span style="color:#00C000"><b>default</b></span>: 1, thus linear).</li>
          <li><b>cycle</b> (<i>bool</i>) &ndash; Whether to cycle beyond num_steps
          (<span style="color:#00C000"><b>default</b></span>: false).</li>
          </ul>
          Inverse time decay:
          <ul>
          <li><b>decay_rate</b> (<i>float</i>) &ndash; Decay rate
          (<span style="color:#C00000"><b>required</b></span>).</li>
          <li><b>staircase</b> (<i>bool</i>) &ndash; Whether to apply decay in a discrete
          staircase, as opposed to continuous, fashion.
          (<span style="color:#00C000"><b>default</b></span>: false).</li>
          </ul>
          Cosine decay:
          <ul>
          <li><b>alpha</b> (<i>float</i>) &ndash; Minimum learning rate value as a fraction of
          learning_rate
          (<span style="color:#00C000"><b>default</b></span>: 0.0).</li>
          </ul>
          Cosine decay with restarts:
          <ul>
          <li><b>t_mul</b> (<i>float</i>) &ndash; Used to derive the number of iterations in the
          i-th period
          (<span style="color:#00C000"><b>default</b></span>: 2.0).</li>
          <li><b>m_mul</b> (<i>float</i>) &ndash; Used to derive the initial learning rate of the
          i-th period
          (<span style="color:#00C000"><b>default</b></span>: 1.0).</li>
          <li><b>alpha</b> (<i>float</i>) &ndash; Minimum learning rate value as a fraction of
          the learning_rate
          (<span style="color:#00C000"><b>default</b></span>: 0.0).</li>
          </ul>
          Linear cosine decay:
          <ul>
          <li><b>num_periods</b> (<i>float</i>) &ndash; Number of periods in the cosine part of
          the decay
          (<span style="color:#00C000"><b>default</b></span>: 0.5).</li>
          <li><b>alpha</b> (<i>float</i>) &ndash; Alpha value
          (<span style="color:#00C000"><b>default</b></span>: 0.0).</li>
          <li><b>beta</b> (<i>float</i>) &ndash; Beta value
          (<span style="color:#00C000"><b>default</b></span>: 0.001).</li>
          </ul>
          Noisy linear cosine decay:
          <ul>
          <li><b>initial_variance</b> (<i>float</i>) &ndash; Initial variance for the noise
          (<span style="color:#00C000"><b>default</b></span>: 1.0).</li>
          <li><b>variance_decay</b> (<i>float</i>) &ndash; Decay for the noise's variance
          (<span style="color:#00C000"><b>default</b></span>: 0.55).</li>
          <li><b>num_periods</b> (<i>float</i>) &ndash; Number of periods in the cosine part of
          the decay
          (<span style="color:#00C000"><b>default</b></span>: 0.5).</li>
          <li><b>alpha</b> (<i>float</i>) &ndash; Alpha value
          (<span style="color:#00C000"><b>default</b></span>: 0.0).</li>
          <li><b>beta</b> (<i>float</i>) &ndash; Beta value
          (<span style="color:#00C000"><b>default</b></span>: 0.001).</li>
          </ul>
      name (string): <span style="color:#0000C0"><b>internal use</b></span>.
      dtype (type): <span style="color:#0000C0"><b>internal use</b></span>.
      min_value (dtype-compatible value): <span style="color:#0000C0"><b>internal use</b></span>.
      max_value (dtype-compatible value): <span style="color:#0000C0"><b>internal use</b></span>.
class_docstr_tok: ["Decaying","hyperparameter","(","specification","key",":","`","decaying","`",",","`","linear","`",",","`","exponential","`",",","`","polynomial","`",",","`","inverse_time","`",",","`","cosine","`",",","`","cosine_restarts","`",",","`","linear_cosine","`",",","`","linear_cosine_noisy","`",")",".","Args",":","decay","(","``","linear","''","|","``","exponential","''","|","``","polynomial","''","|","``","inverse_time","''","|","``","cosine","''","|","``","cosine_restarts","''","|","``","linear_cosine","''","|","``","linear_cosine_noisy","''",")",":","Decay","type",",","see","also","`","TensorFlow","docs","<","https",":","\/\/www.tensorflow.org\/api_docs\/python\/tf\/train",">","`","__","(","<","span","style=","''","color",":","#","C00000","''",">","<","b",">","required","<","\/b",">","<","\/span",">",")",".","unit","(","``","timesteps","''","|","``","episodes","''","|","``","updates","''",")",":","Unit","of","decay","schedule","(","<","span","style=","''","color",":","#","C00000","''",">","<","b",">","required","<","\/b",">","<","\/span",">",")",".","num_steps","(","int",")",":","Number","of","decay","steps","(","<","span","style=","''","color",":","#","C00000","''",">","<","b",">","required","<","\/b",">","<","\/span",">",")",".","initial_value","(","float","|","int",")",":","Initial","value","(","<","span","style=","''","color",":","#","C00000","''",">","<","b",">","required","<","\/b",">","<","\/span",">",")",".","increasing","(","bool",")",":","Whether","to","subtract","the","decayed","value","from","1.0","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","false",")",".","inverse","(","bool",")",":","Whether","to","take","the","inverse","of","the","decayed","value","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","false",")",".","scale","(","float",")",":","Scaling","factor","for","(","inverse",")","decayed","value","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","1.0",")",".","kwargs",":","Additional","arguments","depend","on","decay","mechanism.","<","br",">","Linear","decay",":","<","ul",">","<","li",">","<","b",">","final_value","<","\/b",">","(","<","i",">","float","|","int","<","\/i",">",")","&","ndash",";","Final","value","(","<","span","style=","''","color",":","#","C00000","''",">","<","b",">","required","<","\/b",">","<","\/span",">",")",".","<","\/li",">","<","\/ul",">","Exponential","decay",":","<","ul",">","<","li",">","<","b",">","decay_rate","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Decay","rate","(","<","span","style=","''","color",":","#","C00000","''",">","<","b",">","required","<","\/b",">","<","\/span",">",")",".","<","\/li",">","<","li",">","<","b",">","staircase","<","\/b",">","(","<","i",">","bool","<","\/i",">",")","&","ndash",";","Whether","to","apply","decay","in","a","discrete","staircase",",","as","opposed","to","continuous",",","fashion",".","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","false",")",".","<","\/li",">","<","\/ul",">","Polynomial","decay",":","<","ul",">","<","li",">","<","b",">","final_value","<","\/b",">","(","<","i",">","float","|","int","<","\/i",">",")","&","ndash",";","Final","value","(","<","span","style=","''","color",":","#","C00000","''",">","<","b",">","required","<","\/b",">","<","\/span",">",")",".","<","\/li",">","<","li",">","<","b",">","power","<","\/b",">","(","<","i",">","float","|","int","<","\/i",">",")","&","ndash",";","Power","of","polynomial","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","1",",","thus","linear",")",".","<","\/li",">","<","li",">","<","b",">","cycle","<","\/b",">","(","<","i",">","bool","<","\/i",">",")","&","ndash",";","Whether","to","cycle","beyond","num_steps","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","false",")",".","<","\/li",">","<","\/ul",">","Inverse","time","decay",":","<","ul",">","<","li",">","<","b",">","decay_rate","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Decay","rate","(","<","span","style=","''","color",":","#","C00000","''",">","<","b",">","required","<","\/b",">","<","\/span",">",")",".","<","\/li",">","<","li",">","<","b",">","staircase","<","\/b",">","(","<","i",">","bool","<","\/i",">",")","&","ndash",";","Whether","to","apply","decay","in","a","discrete","staircase",",","as","opposed","to","continuous",",","fashion",".","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","false",")",".","<","\/li",">","<","\/ul",">","Cosine","decay",":","<","ul",">","<","li",">","<","b",">","alpha","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Minimum","learning","rate","value","as","a","fraction","of","learning_rate","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","0.0",")",".","<","\/li",">","<","\/ul",">","Cosine","decay","with","restarts",":","<","ul",">","<","li",">","<","b",">","t_mul","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Used","to","derive","the","number","of","iterations","in","the","i-th","period","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","2.0",")",".","<","\/li",">","<","li",">","<","b",">","m_mul","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Used","to","derive","the","initial","learning","rate","of","the","i-th","period","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","1.0",")",".","<","\/li",">","<","li",">","<","b",">","alpha","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Minimum","learning","rate","value","as","a","fraction","of","the","learning_rate","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","0.0",")",".","<","\/li",">","<","\/ul",">","Linear","cosine","decay",":","<","ul",">","<","li",">","<","b",">","num_periods","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Number","of","periods","in","the","cosine","part","of","the","decay","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","0.5",")",".","<","\/li",">","<","li",">","<","b",">","alpha","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Alpha","value","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","0.0",")",".","<","\/li",">","<","li",">","<","b",">","beta","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Beta","value","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","0.001",")",".","<","\/li",">","<","\/ul",">","Noisy","linear","cosine","decay",":","<","ul",">","<","li",">","<","b",">","initial_variance","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Initial","variance","for","the","noise","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","1.0",")",".","<","\/li",">","<","li",">","<","b",">","variance_decay","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Decay","for","the","noise","'s","variance","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","0.55",")",".","<","\/li",">","<","li",">","<","b",">","num_periods","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Number","of","periods","in","the","cosine","part","of","the","decay","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","0.5",")",".","<","\/li",">","<","li",">","<","b",">","alpha","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Alpha","value","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","0.0",")",".","<","\/li",">","<","li",">","<","b",">","beta","<","\/b",">","(","<","i",">","float","<","\/i",">",")","&","ndash",";","Beta","value","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","0.001",")",".","<","\/li",">","<","\/ul",">","name","(","string",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","dtype","(","type",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","min_value","(","dtype-compatible","value",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","max_value","(","dtype-compatible","value",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">","."]
code: def max_value(self):
      if self.decay == "cosine" or self.decay == "cosine_restarts":
          assert 0.0 <= self.kwargs.get("alpha", 0.0) <= 1.0
          if self.initial_value >= 0.0:
              min_value = self.initial_value * self.kwargs.get(
                  "alpha", 0.0
              )
              max_value = self.initial_value
          else:
              min_value = self.initial_value
              max_value = self.initial_value * self.kwargs.get(
                  "alpha", 0.0
              )
  
      elif self.decay == "exponential" or self.decay == "inverse_time":
          assert 0.0 <= self.kwargs["decay_rate"] <= 1.0
          if self.kwargs["decay_rate"] == 1.0:
              min_value = max_value = self.initial_value
          elif self.initial_value >= 0.0:
              min_value = 0.0
              max_value = self.initial_value
          else:
              min_value = self.initial_value
              max_value = 0.0
  
      elif (
          self.decay == "linear_cosine"
          or self.decay == "linear_cosine_noisy"
      ):
          assert 0.0 <= self.kwargs.get("alpha", 0.0) <= 1.0
          assert 0.0 <= self.kwargs.get("beta", 0.0) <= 1.0
          if self.initial_value >= 0.0:
              min_value = self.initial_value * self.kwargs.get(
                  "beta", 0.001
              )
              max_value = self.initial_value * (
                  1.0
                  + self.kwargs.get("alpha", 0.0)
                  + self.kwargs.get("beta", 0.001)
              )
          else:
              min_value = self.initial_value * (
                  1.0
                  + self.kwargs.get("alpha", 0.0)
                  + self.kwargs.get("beta", 0.001)
              )
              max_value = self.initial_value * self.kwargs.get(
                  "beta", 0.001
              )
  
      elif self.decay == "polynomial":
          if self.kwargs.get("power", 1.0) == 0.0:
              min_value = max_value = self.initial_value
          elif self.initial_value >= self.kwargs["final_value"]:
              min_value = self.kwargs["final_value"]
              max_value = self.initial_value
          else:
              min_value = self.initial_value
              max_value = self.kwargs["final_value"]
  
      assert min_value <= max_value
  
      if self.increasing:
          assert 0.0 <= min_value <= max_value <= 1.0
          min_value, max_value = 1.0 - max_value, 1.0 - min_value
  
      if self.inverse:
          assert 0.0 < min_value <= max_value
          min_value, max_value = 1.0 / max_value, 1.0 / min_value
  
      if self.scale == 1.0:
          pass
      elif self.scale >= 0.0:
          min_value, max_value = (
              self.scale * min_value,
              self.scale * max_value,
          )
      else:
          min_value, max_value = (
              self.scale * max_value,
              self.scale * min_value,
          )
  
      return self.spec.py_type()(max_value)
  
file_path: tensorforce/tensorforce/core/parameters/decaying.py
imports: import tensorflow
  from tensorforce import TensorforceError, util
  from tensorforce.core import tf_util
  from tensorforce.core.parameters import Parameter
label_desc: Use image node_id 3 for calling the Decaying obj's underlying member method code with example usage: obj.max_value() and returns: self