Implement the sigmoid activation function:
σ(x)=1+e−x1Return a float when x is a scalar. For a list or nested list, return a NumPy array of floats with the same shape as x.
Input: x = [0, 2, -2]
Output: [0.5, 0.88079708, 0.11920292]
Input: x = 0
Output: 0.5
Input: x = [[-1, 0], [1, 2]]
Output: [[0.26894142, 0.5], [0.73105858, 0.88079708]]
Convert the input with np.asarray(x, dtype=float) before applying elementwise operations.
Use np.exp on the negated array when computing the sigmoid expression.
Sign in to take notes on this problem
Accepts: any
Implement the sigmoid activation function:
σ(x)=1+e−x1Return a float when x is a scalar. For a list or nested list, return a NumPy array of floats with the same shape as x.
Input: x = [0, 2, -2]
Output: [0.5, 0.88079708, 0.11920292]
Input: x = 0
Output: 0.5
Input: x = [[-1, 0], [1, 2]]
Output: [[0.26894142, 0.5], [0.73105858, 0.88079708]]
Convert the input with np.asarray(x, dtype=float) before applying elementwise operations.
Use np.exp on the negated array when computing the sigmoid expression.
Sign in to take notes on this problem
Accepts: any