ELU Activation
ELU Activation
The Exponential Linear Unit (ELU) is an activation function that pushes mean activations closer to zero, which speeds up learning. Unlike ReLU, ELU produces a smooth curve for negative inputs, reducing the impact of the vanishing gradient problem.
Given a list of values and a parameter alpha, apply the ELU activation to each element.
Formula
ELU(x)=xif x>0 ELU(x)=α⋅(ex−1)if x≤0The parameter alpha controls the negative saturation value. As x approaches negative infinity, ELU(x) approaches -alpha.
Examples
Input:
x = [1.0, -1.0, 0.0, 2.0, -0.5], alpha = 1.0
Output:
[1.0, -0.6321, 0.0, 2.0, -0.3935]
Positive values pass through unchanged. Negative values are mapped through alpha * (exp(x) - 1), approaching -alpha for very negative x.
Input:
x = [-1.0, -2.0, -3.0], alpha = 2.0
Output:
[-1.2642, -1.7293, -1.9004]
With alpha = 2.0 the negative saturation value doubles compared to alpha = 1.0.
Hint 1
Use math.exp(v) to compute the exponential. The boundary condition is at x = 0: for x > 0 return x, for x <= 0 return alpha * (exp(x) - 1).
Hint 2
When alpha = 0, all negative values map to 0 (similar to ReLU). When alpha = 1, the function is continuous and smooth at x = 0.
Requirements
- Apply the ELU formula element-wise to each value in the input list
- Use the alpha parameter for negative values
- Return a list of floats with the same length as the input
Constraints
- Input list has at least one element
- alpha >= 0
- Return a list of floats with the same length as input
- Time limit: 300 ms
Try Similar Problems
Log in to take notes on this problem
Accepts: array
Accepts: number
ELU Activation
ELU Activation
The Exponential Linear Unit (ELU) is an activation function that pushes mean activations closer to zero, which speeds up learning. Unlike ReLU, ELU produces a smooth curve for negative inputs, reducing the impact of the vanishing gradient problem.
Given a list of values and a parameter alpha, apply the ELU activation to each element.
Formula
ELU(x)=xif x>0 ELU(x)=α⋅(ex−1)if x≤0The parameter alpha controls the negative saturation value. As x approaches negative infinity, ELU(x) approaches -alpha.
Examples
Input:
x = [1.0, -1.0, 0.0, 2.0, -0.5], alpha = 1.0
Output:
[1.0, -0.6321, 0.0, 2.0, -0.3935]
Positive values pass through unchanged. Negative values are mapped through alpha * (exp(x) - 1), approaching -alpha for very negative x.
Input:
x = [-1.0, -2.0, -3.0], alpha = 2.0
Output:
[-1.2642, -1.7293, -1.9004]
With alpha = 2.0 the negative saturation value doubles compared to alpha = 1.0.
Hint 1
Use math.exp(v) to compute the exponential. The boundary condition is at x = 0: for x > 0 return x, for x <= 0 return alpha * (exp(x) - 1).
Hint 2
When alpha = 0, all negative values map to 0 (similar to ReLU). When alpha = 1, the function is continuous and smooth at x = 0.
Requirements
- Apply the ELU formula element-wise to each value in the input list
- Use the alpha parameter for negative values
- Return a list of floats with the same length as the input
Constraints
- Input list has at least one element
- alpha >= 0
- Return a list of floats with the same length as input
- Time limit: 300 ms
Try Similar Problems
Log in to take notes on this problem
Accepts: array
Accepts: number