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

Function softplus

neural_network/activation_functions/softplus.py:12–31  ·  view source on GitHub ↗

Implements the Softplus activation function. Parameters: vector (np.ndarray): The input array for the Softplus activation. Returns: np.ndarray: The input array after applying the Softplus activation. Formula: f(x) = ln(1 + e^x) Examples: >>> softplus(np.a

(vector: np.ndarray)

Source from the content-addressed store, hash-verified

10
11
12def softplus(vector: np.ndarray) -> np.ndarray:
13 """
14 Implements the Softplus activation function.
15
16 Parameters:
17 vector (np.ndarray): The input array for the Softplus activation.
18
19 Returns:
20 np.ndarray: The input array after applying the Softplus activation.
21
22 Formula: f(x) = ln(1 + e^x)
23
24 Examples:
25 >>> softplus(np.array([2.3, 0.6, -2, -3.8]))
26 array([2.39554546, 1.03748795, 0.12692801, 0.02212422])
27
28 >>> softplus(np.array([-9.2, -0.3, 0.45, -4.56]))
29 array([1.01034298e-04, 5.54355244e-01, 9.43248946e-01, 1.04077103e-02])
30 """
31 return np.log(1 + np.exp(vector))
32
33
34if __name__ == "__main__":

Callers 1

mishFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected