Sigmoid Function
~10 mincode completion
Implement that applies the sigmoid function element-wise.
Examples
z=0 gives exactly 0.5
- Input
- sigmoid(0)
- Output
- 0.5
Large positive z approaches 1
- Input
- sigmoid(100)
- Output
- 1
Large negative z approaches 0
- Input
- sigmoid(-100)
- Output
- 0
Hints
Hint 1
applies elementwise, so negate the whole array and exponentiate it in one go.
Hint 2
Do not forget to negation in exp. That step is easy to skip.
Requirements
z: Scalar or NumPy arrayReturn Values in (0, 1), same shape as z.
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Try similar problems(1)
Where this shows up
~10 min
••••••••••••••
7 employers weight this skill
2 health and bio companies, 2 quant funds, 2 enterprise vendors, 1 AI product company. Top match scores 87.
Python
import numpy as np
def sigmoid(z):
"""
Apply the sigmoid function element-wise.
Args:
z: Scalar or NumPy array
Returns:
Values in (0, 1), same shape as z.
"""
# YOUR CODE HERE
pass