All problems
ELU
Problem
Apply the exponential linear unit element-wise: f(x) = x if x >= 0, else alpha * (exp(x) - 1).
The signature is elu(x, alpha=1.0). Return a list.
Hint
Non-negative values pass through unchanged; negatives follow alpha * (exp(x) - 1).
Test cases
case 1
in: [[0,1,2]]
expected: [0,1,2]
case 2
in: [[-1],1]
expected: [-0.6321205588]
case 3
in: [[-2,-0.5],2]
expected: [-1.7293294335,-0.7869386806]
case 4
in: [[-3],1.5]
expected: [-1.4253193974]
Starter codePython
import math
def elu(x, alpha=1.0):
# Your code here
pass4 test cases · run your code against them in the editor