Skip to content
DeepForgeby svx
All problems
MediumCalculusca-339

Swish Second Derivative Vector

Problem

For swish(z) = z * sigmoid(z), the second derivative is 2 s (1 - s) + z s (1 - s) (1 - 2 s) with s = sigmoid(z).

Given the values z, return the second derivative list.

Hint

Differentiate f' = s + z s (1 - s) term by term.

Test cases

case 1
in: [[0,1,-1]]
expected: [0.5,0.3023661188100153,0.3023661188100153]
case 2
in: [[2,-2]]
expected: [0.050062168694707004,0.05006216869470692]
case 3
in: [[0.5,3]]
expected: [0.4412290269770286,-0.03232140452100614]
Starter codePython
def swish_second_derivative(values):
    # Your code here
    pass

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