Problems
Loading...
1 / 1

SELU Activation

Activation Functions
Easy

The Scaled Exponential Linear Unit (SELU) is a self-normalizing activation function. When used with proper weight initialization (LeCun normal), SELU automatically maintains zero mean and unit variance activations across layers, eliminating the need for batch normalization.

Given a list of values, apply the SELU activation to each element using the fixed constants lambda and alpha.

Formula

SELU(x)=λxif x>0SELU(x) = \lambda \cdot x \quad \text{if } x > 0 SELU(x)=λα(ex1)if x0SELU(x) = \lambda \cdot \alpha \cdot (e^x - 1) \quad \text{if } x \le 0

The constants are derived analytically to preserve self-normalizing properties:

λ1.0507α1.6733\lambda \approx 1.0507 \qquad \alpha \approx 1.6733
Loading visualization...

Examples

Input:

x = [1.0, -1.0, 0.0]

Output:

[1.0507, -1.1113, 0.0]

Positive values are scaled by lambda. Negative values are scaled by lambda * alpha * (exp(x) - 1). Zero maps to zero.

Input:

x = [0.5, 1.5, 2.5]

Output:

[0.5254, 1.5761, 2.6268]

All positive values are simply multiplied by lambda (approximately 1.0507).

Hint 1

Define the two constants at the top of your function. For positive x, return lambda * x. For non-positive x, return lambda * alpha * (exp(x) - 1).

Hint 2

Note that SELU(0) = lambda * alpha * (exp(0) - 1) = 0, so the function is continuous at x = 0.

Requirements

  • Apply the SELU formula element-wise
  • Use the exact constants: lambda = 1.0507009873554804934193349852946, alpha = 1.6732632423543772848170429916717
  • Return a list of floats with the same length as input

Constraints

  • Input list has at least one element
  • Use the provided constant values for lambda and alpha
  • Return a list of floats with the same length as input
  • Time limit: 300 ms
Try Similar Problems