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

Function swish

neural_network/activation_functions/swish.py:53–69  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

51
52
53def 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
72if __name__ == "__main__":

Callers

nothing calls this directly

Calls 1

sigmoidFunction · 0.70

Tested by

no test coverage detected