Sigmoid Derivative

EasyMachine LearningMathArray

Description

Given an array of pre-activation values, return the derivative of the sigmoid at each value: s(x) * (1 - s(x)), where s(x) = 1 / (1 + e^-x). Round each result to 4 decimal places.

Examples

Input:[0]
Output:[0.25]
Explanation:

The sigmoid slope is largest at zero, where it reaches one quarter, and shrinks toward zero as the input moves far from the origin.

Input:[1,-1]
Output:[0.1966,0.1966]
Explanation:

The sigmoid slope is largest at zero, where it reaches one quarter, and shrinks toward zero as the input moves far from the origin.

Input:[2,-2]
Output:[0.105,0.105]
Explanation:

The sigmoid slope is largest at zero, where it reaches one quarter, and shrinks toward zero as the input moves far from the origin.

Constraints

  • 1 ≤ length ≤ 10⁴

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.