Parameters: vector (np.ndarray): A numpy array consisting of real values trainable_parameter: Use to implement various Swish Activation Functions Returns: swish_vec (np.ndarray): The input numpy array, after applying swish Examples: >>> swish(np.array([-1.
(vector: np.ndarray, trainable_parameter: int)
| 51 | |
| 52 | |
| 53 | def swish(vector: np.ndarray, trainable_parameter: int) -> np.ndarray: |
| 54 | """ |
| 55 | Parameters: |
| 56 | vector (np.ndarray): A numpy array consisting of real values |
| 57 | trainable_parameter: Use to implement various Swish Activation Functions |
| 58 | |
| 59 | Returns: |
| 60 | swish_vec (np.ndarray): The input numpy array, after applying swish |
| 61 | |
| 62 | Examples: |
| 63 | >>> swish(np.array([-1.0, 1.0, 2.0]), 2) |
| 64 | array([-0.11920292, 0.88079708, 1.96402758]) |
| 65 | |
| 66 | >>> swish(np.array([-2]), 1) |
| 67 | array([-0.23840584]) |
| 68 | """ |
| 69 | return vector * sigmoid(trainable_parameter * vector) |
| 70 | |
| 71 | |
| 72 | if __name__ == "__main__": |