Implements the Mish activation function. Parameters: vector (np.ndarray): The input array for Mish activation. Returns: np.ndarray: The input array after applying the Mish activation. Formula: f(x) = x * tanh(softplus(x)) = x *
(vector: np.ndarray)
| 12 | |
| 13 | |
| 14 | def mish(vector: np.ndarray) -> np.ndarray: |
| 15 | """ |
| 16 | Implements the Mish activation function. |
| 17 | |
| 18 | Parameters: |
| 19 | vector (np.ndarray): The input array for Mish activation. |
| 20 | |
| 21 | Returns: |
| 22 | np.ndarray: The input array after applying the Mish activation. |
| 23 | |
| 24 | Formula: |
| 25 | f(x) = x * tanh(softplus(x)) = x * tanh(ln(1 + e^x)) |
| 26 | |
| 27 | Examples: |
| 28 | >>> mish(vector=np.array([2.3,0.6,-2,-3.8])) |
| 29 | array([ 2.26211893, 0.46613649, -0.25250148, -0.08405831]) |
| 30 | |
| 31 | >>> mish(np.array([-9.2, -0.3, 0.45, -4.56])) |
| 32 | array([-0.00092952, -0.15113318, 0.33152014, -0.04745745]) |
| 33 | |
| 34 | """ |
| 35 | return vector * np.tanh(softplus(vector)) |
| 36 | |
| 37 | |
| 38 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected