MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / sigmoid

Function sigmoid

maths/sigmoid.py:14–33  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

12
13
14def 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
36if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected