Implements the Sigmoid Linear Unit (SiLU) or swish function Parameters: vector (np.ndarray): A numpy array consisting of real values Returns: swish_vec (np.ndarray): The input numpy array, after applying swish Examples: >>> sigmoid_linear_unit(np.array([-1.0,
(vector: np.ndarray)
| 31 | |
| 32 | |
| 33 | def sigmoid_linear_unit(vector: np.ndarray) -> np.ndarray: |
| 34 | """ |
| 35 | Implements the Sigmoid Linear Unit (SiLU) or swish function |
| 36 | |
| 37 | Parameters: |
| 38 | vector (np.ndarray): A numpy array consisting of real values |
| 39 | |
| 40 | Returns: |
| 41 | swish_vec (np.ndarray): The input numpy array, after applying swish |
| 42 | |
| 43 | Examples: |
| 44 | >>> sigmoid_linear_unit(np.array([-1.0, 1.0, 2.0])) |
| 45 | array([-0.26894142, 0.73105858, 1.76159416]) |
| 46 | |
| 47 | >>> sigmoid_linear_unit(np.array([-2])) |
| 48 | array([-0.23840584]) |
| 49 | """ |
| 50 | return vector * sigmoid(vector) |
| 51 | |
| 52 | |
| 53 | def swish(vector: np.ndarray, trainable_parameter: int) -> np.ndarray: |