Implements the sigmoid function Parameters: vector (np.array): A numpy array of shape (1,n) consisting of real values Returns: sigmoid_vec (np.array): The input numpy array, after applying sigmoid. Examples: >>> sigmoid(np.array([-1.0, 1.0, 2.
(vector: np.ndarray)
| 12 | |
| 13 | |
| 14 | def sigmoid(vector: np.ndarray) -> np.ndarray: |
| 15 | """ |
| 16 | Implements the sigmoid function |
| 17 | |
| 18 | Parameters: |
| 19 | vector (np.array): A numpy array of shape (1,n) |
| 20 | consisting of real values |
| 21 | |
| 22 | Returns: |
| 23 | sigmoid_vec (np.array): The input numpy array, after applying |
| 24 | sigmoid. |
| 25 | |
| 26 | Examples: |
| 27 | >>> sigmoid(np.array([-1.0, 1.0, 2.0])) |
| 28 | array([0.26894142, 0.73105858, 0.88079708]) |
| 29 | |
| 30 | >>> sigmoid(np.array([0.0])) |
| 31 | array([0.5]) |
| 32 | """ |
| 33 | return 1 / (1 + np.exp(-vector)) |
| 34 | |
| 35 | |
| 36 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected