← Problems4. Sigmoid Function
EasyActivation FunctionsNeural NetworksNumPy
Implement the sigmoid activation function.
σ(x)=1+e−x1
The sigmoid maps any real number to the range (0,1), making it useful for binary classification outputs and gates in recurrent networks.
Properties to note:
- σ(0)=0.5
- σ(x)→1 as x→+∞
- σ(x)→0 as x→−∞
- σ′(x)=σ(x)(1−σ(x))
Example
Input: x = 0
Output: 0.5
Input: x = 2
Output: ≈ 0.8808
Constraints
- Your function should work on both scalars and NumPy arrays.