TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
←

68. ELU and SELU Activations

Easy

ELU (Exponential Linear Unit) fixes the dying ReLU problem by using a smooth negative region instead of hard-zeroing. For negative inputs, ELU outputs a small negative value that saturates toward -alpha, allowing mean activations to stay closer to zero.

SELU (Scaled ELU) is a self-normalizing variant — activations in deep networks automatically converge to zero mean and unit variance, eliminating the need for explicit normalization layers.

ELU:

f(x) = x            if x > 0
f(x) = alpha * (exp(x) - 1)   if x <= 0

Default: alpha = 1.0

SELU:

f(x) = scale * x                         if x > 0
f(x) = scale * alpha * (exp(x) - 1)      if x <= 0

Fixed constants: scale = 1.0507009873554804, alpha = 1.6732631921096593

Signature: def elu_selu(x, mode='elu', alpha=1.0)

  • x: input array (any shape)
  • mode: 'elu' or 'selu'
  • alpha: slope parameter for ELU (ignored for SELU, which uses its fixed alpha)
  • Returns: same shape as x

Math

ELU(x)={xα(ex−1)​x>0x≤0​SELU(x)=λ{xα(ex−1)​x>0x≤0​λ=1.0507, α=1.6733

Related problems

  • ELU and SELU (PyTorch)easyPyTorch

Asked at

NumPy

import numpy as np

 

def elu_selu(...):

    pass

🔒

Premium problem

Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.

Upgrade to PremiumBack to problems

Already premium?