Ejemplo n.º 1
0
def Selu(alpha=1.6732632423543772848170429916717,
         lmbda=1.0507009873554804934193349852946):
  r"""Returns an `Elu`-like layer with an additional scaling/slope parameter.

  .. math::
      f(x) = \left\{ \begin{array}{cl}
          \lambda \cdot \alpha \cdot (e^x - 1) & \text{if}\ x \leq 0, \\
          \lambda \cdot x                      & \text{otherwise}.
      \end{array} \right.

  Args:
    alpha: Coefficient multiplying the exponential, for negative inputs.
    lmbda: Coefficient scaling the whole function.
  """
  return Fn('Selu', lambda x: lmbda * np.where(x > 0, x, alpha * np.expm1(x)))
Ejemplo n.º 2
0
def Elu(a=1.):
  r"""Returns a ReLU-like layer with exponential outputs for negative inputs.

  .. math::
      f(x) = \left\{ \begin{array}{cl}
          a \cdot (e^x - 1) & \text{if}\ x \leq 0, \\
          x                 & \text{otherwise}.
      \end{array} \right.

  (Asymptotically, :math:`f(x)\rightarrow -a` as :math:`x\rightarrow - \infty`.)

  Args:
    a: Coefficient multiplying the exponential, for negative inputs.
  """
  return Fn('Elu', lambda x: np.where(x > 0, x, a * np.expm1(x)))
Ejemplo n.º 3
0
def Selu(x,
         alpha=1.6732632423543772848170429916717,
         lmbda=1.0507009873554804934193349852946):
    return lmbda * np.where(x > 0, x, alpha * np.expm1(x))
Ejemplo n.º 4
0
def Elu(x, a=1., **unused_kwargs):
    return np.where(x > 0, x, a * np.expm1(x))
Ejemplo n.º 5
0
def Elu(a=1.):
    return Fn('Elu', lambda x: np.where(x > 0, x, a * np.expm1(x)))
Ejemplo n.º 6
0
def Elu(x, a=1.):
    return np.where(x > 0, x, a * np.expm1(x))