Skip to content
DeepForgeby svx
All problems
EasyCalculusca-242

Sigmoid Derivative Backprop

Problem

The logistic sigmoid s(x) = 1 / (1 + exp(-x)) has derivative s(x) * (1 - s(x)).

Given an upstream gradient grad and a scalar pre-activation x, return grad * s(x) * (1 - s(x)).

Hint

The sigmoid derivative peaks at x = 0 with value 0.25.

Test cases

case 1
in: [1,0]
expected: 0.25
case 2
in: [2,1]
expected: 0.3932238664829637
case 3
in: [-1,-2]
expected: -0.1049935854035065
case 4
in: [0,5]
expected: 0
Starter codePython
def sigmoid_backward(grad, x):
    # Your code here
    pass

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