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

Function sigmoid_linear_unit

neural_network/activation_functions/swish.py:33–50  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

31
32
33def 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
53def swish(vector: np.ndarray, trainable_parameter: int) -> np.ndarray:

Callers

nothing calls this directly

Calls 1

sigmoidFunction · 0.70

Tested by

no test coverage detected