Skip to content
DeepForgeby svx
All problems
EasyCalculusca-277

ELU Derivative Vector

Problem

The exponential linear unit is f(z) = z for z > 0 and f(z) = alpha * (exp(z) - 1) otherwise, so f'(z) = 1 for z > 0 and alpha * exp(z) otherwise.

Given the pre-activations and alpha (default 1.0), return the derivative list.

Hint

For the negative side differentiate alpha * (exp(z) - 1).

Test cases

case 1
in: [[0,1,-1]]
expected: [1,1,0.36787944117144233]
case 2
in: [[-2,-2]]
expected: [0.1353352832366127,0.1353352832366127]
case 3
in: [[0.5,-0.5],0.5]
expected: [1,0.3032653298563167]
Starter codePython
def elu_derivative(values, alpha=1.0):
    # Your code here
    pass

3 test cases · run your code against them in the editor