BackpropagationHard
Sigmoid Gradient (Backprop)
~15 mincode completion
Implement sigmoid_gradient(z) that returns the derivative of sigmoid at each element of z.
Examples
z=0: maximum gradient = 0.25
- Input
- sigmoid_gradient(0)
- Output
- 0.25
Large positive z: gradient near 0
- Input
- sigmoid_gradient(100)
- Output
- 0
Symmetric: gradient same at +1 and -1
- Input
- sigmoid_gradient(1)
- Output
- 0.19661
Hints
Hint 1
applies elementwise, so negate the whole array and exponentiate it in one go.
Hint 2
Do not forget to 1 minus s factor. That step is easy to skip.
Requirements
z: Scalar or NumPy arrayReturn sigma(z) * (1 - sigma(z)), same shape as z.
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Where this shows up
~15 min
••••••••••••••••
8 employers weight this skill
4 frontier labs, 2 big tech firms, 1 autonomy company, 1 enterprise vendor. Top match scores 91.
Python
import numpy as np
def sigmoid_gradient(z):
"""
Compute the gradient of the sigmoid function.
Args:
z: Scalar or NumPy array
Returns:
sigma(z) * (1 - sigma(z)), same shape as z.
"""
# YOUR CODE HERE
pass