class_docstr: Trainer extension to shift an optimizer attribute.
  
  The new value is computed according to the fomula below:
  new_attr = init_attr * (1 + gamma * iter) ^ (- power), which is compatible
  to the ``inv`` learning rate policy in Caffe.
  
  The typical use is to decrease the learning rate during the training.
  
  This extension is also called before the training loop starts by default.
  
  Args:
      attr (str): Name of the attribute to shift.
      gamma (float): Parameter used to compute the new value. Refer to the
          fomula above. Note that gamma is assumed to be nonegative.
      power (float): Parameter used to compute the new value. Refer to the
          fomula above.
      init (float): Initial value of the attribute. If it is ``None``, the
          extension extracts the attribute at the first call and uses it as
          the initial value.
      target (float): Target value of the attribute. If the attribute reaches
          this value, the shift stops.
      optimizer (~chainer.Optimizer): Target optimizer to adjust the
          attribute. If it is ``None``, the main optimizer of the updater is
          used.
class_docstr_tok: ["Trainer","extension","to","shift","an","optimizer","attribute",".","The","new","value","is","computed","according","to","the","fomula","below",":","new_attr","=","init_attr","*","(","1","+","gamma","*","iter",")","^","(","-","power",")",",","which","is","compatible","to","the","``","inv","``","learning","rate","policy","in","Caffe",".","The","typical","use","is","to","decrease","the","learning","rate","during","the","training",".","This","extension","is","also","called","before","the","training","loop","starts","by","default",".","Args",":","attr","(","str",")",":","Name","of","the","attribute","to","shift",".","gamma","(","float",")",":","Parameter","used","to","compute","the","new","value",".","Refer","to","the","fomula","above",".","Note","that","gamma","is","assumed","to","be","nonegative",".","power","(","float",")",":","Parameter","used","to","compute","the","new","value",".","Refer","to","the","fomula","above",".","init","(","float",")",":","Initial","value","of","the","attribute",".","If","it","is","``","None","``",",","the","extension","extracts","the","attribute","at","the","first","call","and","uses","it","as","the","initial","value",".","target","(","float",")",":","Target","value","of","the","attribute",".","If","the","attribute","reaches","this","value",",","the","shift","stops",".","optimizer","(","~chainer.Optimizer",")",":","Target","optimizer","to","adjust","the","attribute",".","If","it","is","``","None","``",",","the","main","optimizer","of","the","updater","is","used","."]
code: def __call__(self, trainer):
      self._t += 1
  
      optimizer = self._get_optimizer(trainer)
      value = self._init * (1 + self._gamma * self._t) ** (-self._power)
      if self._target is not None:
          if self._power < 0:
              # almost same as value = min(value, self._target), but this
              # line supports negative values, too
              if value / self._target > 1:
                  value = self._target
          else:
              # ditto
              if value / self._target < 1:
                  value = self._target
      self._update_value(optimizer, value)
  
file_path: chainer/chainer/training/extensions/inverse_shift.py
imports: from __future__ import division
  import numpy
  from chainer.training import extension
label_desc: Use image node_id 3 for calling the InverseShift obj's underlying member method code with example usage: obj.__call__(trainer) without return types