File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
neural_network/activation_functions Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Mish Activation Function
3+
4+ Use Case: Improved version of the ReLU activation function used in Computer Vision.
5+ For more detailed information, you can refer to the following link:
6+ https://en.wikipedia.org/wiki/Rectifier_(neural_networks)#Mish
7+ """
8+
9+ import numpy as np
10+
11+
12+ def mish (vector : np .ndarray ) -> np .ndarray :
13+ """
14+ Implements the Mish activation function.
15+
16+ Parameters:
17+ vector (np.ndarray): The input array for Mish activation.
18+
19+ Returns:
20+ np.ndarray: The input array after applying the Mish activation.
21+
22+ Formula:
23+ f(x) = x * tanh(softplus(x)) = x * tanh(ln(1 + e^x))
24+
25+ Examples:
26+ >>> mish(vector=np.array([2.3,0.6,-2,-3.8]))
27+ array([ 2.26211893, 0.46613649, -0.25250148, -0.08405831])
28+
29+ >>> mish(np.array([-9.2, -0.3, 0.45, -4.56]))
30+ array([-0.00092952, -0.15113318, 0.33152014, -0.04745745])
31+
32+ """
33+ return vector * np .tanh (np .log (1 + np .exp (vector )))
34+
35+
36+ if __name__ == "__main__" :
37+ import doctest
38+
39+ doctest .testmod ()
You can’t perform that action at this time.
0 commit comments