(self, x, is_first, is_last)
return x
Adds output saved from earlier layer to x if at residual period.
Adds output saved from earlier layer to x if at residual period.
Adds output saved from earlier layer to x if at residual period .
def apply_residual(self, x, is_first, is_last):
    """Adds output saved from earlier layer to x if at residual period."""
    if not self.hparams.use_residual:
      return x
    if self.output_for_residual is None:
      return x
    if self.output_for_residual.get_shape()[-1] != x.get_shape()[-1]:
      # shape mismatch; e.g. change in number of filters
      self.residual_reset()
      return x
    if self.residual_counter % self.residual_period == 0:
      if not is_first and not is_last:
        x += self.output_for_residual
    return x
def apply_residual ( self , x , is_first , is_last ) : if not self . hparams . use_residual : return x if self . output_for_residual is None : return x if self . output_for_residual . get_shape ( ) [ - 1 ] != x . get_shape ( ) [ - 1 ] : # shape mismatch; e.g. change in number of filters self . residual_reset ( ) return x if self . residual_counter % self . residual_period == 0 : if not is_first and not is_last : x += self . output_for_residual return x