v9.1.1
Menu

Sigmoid Gradient

easyFREEActivation FunctionsDeep LearningDeep Learning 1

Problem Statement

Compute the derivative of the Sigmoid function given the activation output.

Background

The Sigmoid function is defined as: σ(z)=11+e−z\sigma(z) = \frac{1}{1 + e^{-z}}

A useful property is that its derivative can be computed directly from the output:

  • If g=σ(z)g = \sigma(z), then the derivative g′(z)=g×(1−g)g'(z) = g \times (1 - g)

This makes backpropagation efficient since we already have the sigmoid output from the forward pass.

Your Task

Write a function sigmoid_derivative(sigmoid_output) that returns the gradient values for each element.

Output Format

Return a list of floats representing the derivatives. Round each value to 4 decimal places.

Example

Input
sigmoid_output=[0.5, 0.8]
Output
[0.25, 0.16]
Reasoning
  • Input: sigmoid_output holds values g=σ(z)g = \sigma(z) that have already come out of the sigmoid in the forward pass, so each lies between 0 and 1. Here g1=0.5g_1 = 0.5 and g2=0.8g_2 = 0.8; the original zz values are never needed.
  • Math: each element is treated on its own with σ′(z)=g(1−g)\sigma'(z) = g(1 - g).
  • For g1=0.5g_1 = 0.5: 1−g1=0.51 - g_1 = 0.5, so 0.5×0.5=0.250.5 \times 0.5 = 0.25.
  • For g2=0.8g_2 = 0.8: 1−g2=0.21 - g_2 = 0.2, so 0.8×0.2=0.160.8 \times 0.2 = 0.16, which stays 0.160.16 after rounding to 4 decimal places.
  • Output: [0.25, 0.16], a list with one gradient per input value and the same length as the input.
  • Notice: 0.250.25 is the largest value the derivative can ever take, reached at g=0.5g = 0.5 (the sigmoid's steepest point, z=0z = 0). As gg approaches 0 or 1 the gradient shrinks toward 0, which is why saturated sigmoids learn slowly. The formula is also symmetric, so gg and 1−g1 - g give the same gradient: 0.250.25 and 0.750.75 both give 0.18750.1875.

Constraints

  • 0 <= sigmoid_output[i] <= 1 for each element
  • List length: 1 to 100 elements

Learn this in

More from Deep Learning 1

solution.py

Test results

Sign in to run your code against the test cases.