parameters: (A, non_linearity)
docstring: Returns required activation for a tensor based on the inputs
  
      non_linearity is either a callable or a value in
          ['tanh', 'sigmoid', 'relu', 'quantTanh', 'quantSigm', 'quantSigm4']
docstring_summary: Returns required activation for a tensor based on the inputs
docstring_tokens: Returns required activation for a tensor based on the inputs
function: def gen_non_linearity(A, non_linearity):
      '''
      Returns required activation for a tensor based on the inputs
  
      non_linearity is either a callable or a value in
          ['tanh', 'sigmoid', 'relu', 'quantTanh', 'quantSigm', 'quantSigm4']
      '''
      if non_linearity == "tanh":
          return math_ops.tanh(A)
      elif non_linearity == "sigmoid":
          return math_ops.sigmoid(A)
      elif non_linearity == "relu":
          return gen_math_ops.maximum(A, 0.0)
      elif non_linearity == "quantTanh":
          return gen_math_ops.maximum(gen_math_ops.minimum(A, 1.0), -1.0)
      elif non_linearity == "quantSigm":
          A = (A + 1.0) / 2.0
          return gen_math_ops.maximum(gen_math_ops.minimum(A, 1.0), 0.0)
      elif non_linearity == "quantSigm4":
          A = (A + 2.0) / 4.0
          return gen_math_ops.maximum(gen_math_ops.minimum(A, 1.0), 0.0)
      else:
          # non_linearity is a user specified function
          if not callable(non_linearity):
              raise ValueError("non_linearity is either a callable or a value " +
                               + "['tanh', 'sigmoid', 'relu', 'quantTanh', " +
                               "'quantSigm'")
          return non_linearity(A)
function_tokens: def gen_non_linearity ( A , non_linearity ) : if non_linearity == "tanh" : return math_ops . tanh ( A ) elif non_linearity == "sigmoid" : return math_ops . sigmoid ( A ) elif non_linearity == "relu" : return gen_math_ops . maximum ( A , 0.0 ) elif non_linearity == "quantTanh" : return gen_math_ops . maximum ( gen_math_ops . minimum ( A , 1.0 ) , - 1.0 ) elif non_linearity == "quantSigm" : A = ( A + 1.0 ) / 2.0 return gen_math_ops . maximum ( gen_math_ops . minimum ( A , 1.0 ) , 0.0 ) elif non_linearity == "quantSigm4" : A = ( A + 2.0 ) / 4.0 return gen_math_ops . maximum ( gen_math_ops . minimum ( A , 1.0 ) , 0.0 ) else : # non_linearity is a user specified function if not callable ( non_linearity ) : raise ValueError ( "non_linearity is either a callable or a value " + + "['tanh', 'sigmoid', 'relu', 'quantTanh', " + "'quantSigm'" ) return non_linearity ( A )