(self)
Update the model parameters based on current gradients.

        Optionally, will employ gradient modification or update learning
        rate.
Update the model parameters based on current gradients.
Update the model parameters based on current gradients .
def step(self):
        """Update the model parameters based on current gradients.

        Optionally, will employ gradient modification or update learning
        rate.
        """
        self._step += 1

        # Decay method used in tensor2tensor.
        if self.decay_method == "noam":
            self._set_rate(
                self.original_lr *
                (self.model_size ** (-0.5) *
                 min(self._step ** (-0.5),
                     self._step * self.warmup_steps**(-1.5))))
        # Decay based on start_decay_steps every decay_steps
        else:
            if ((self.start_decay_steps is not None) and (
                     self._step >= self.start_decay_steps)):
                self.start_decay = True
            if self.start_decay:
                if ((self._step - self.start_decay_steps)
                   % self.decay_steps == 0):
                    self.learning_rate = self.learning_rate * self.lr_decay

        if self.method != 'sparseadam':
            self.optimizer.param_groups[0]['lr'] = self.learning_rate

        if self.max_grad_norm:
            clip_grad_norm_(self.params, self.max_grad_norm)
        self.optimizer.step()
def step ( self ) : self . _step += 1 # Decay method used in tensor2tensor. if self . decay_method == "noam" : self . _set_rate ( self . original_lr * ( self . model_size ** ( - 0.5 ) * min ( self . _step ** ( - 0.5 ) , self . _step * self . warmup_steps ** ( - 1.5 ) ) ) ) # Decay based on start_decay_steps every decay_steps else : if ( ( self . start_decay_steps is not None ) and ( self . _step >= self . start_decay_steps ) ) : self . start_decay = True if self . start_decay : if ( ( self . _step - self . start_decay_steps ) % self . decay_steps == 0 ) : self . learning_rate = self . learning_rate * self . lr_decay if self . method != 'sparseadam' : self . optimizer . param_groups [ 0 ] [ 'lr' ] = self . learning_rate if self . max_grad_norm : clip_grad_norm_ ( self . params , self . max_grad_norm ) self . optimizer . step ( )