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

Function sigmoid

neural_network/two_hidden_layers_neural_network.py:226–236  ·  view source on GitHub ↗

Applies sigmoid activation function. return normalized values >>> sigmoid(np.array(([1, 0, 2], [1, 0, 0]), dtype=np.float64)) array([[0.73105858, 0.5 , 0.88079708], [0.73105858, 0.5 , 0.5 ]])

(value: np.ndarray)

Source from the content-addressed store, hash-verified

224
225
226def sigmoid(value: np.ndarray) -> np.ndarray:
227 """
228 Applies sigmoid activation function.
229
230 return normalized values
231
232 >>> sigmoid(np.array(([1, 0, 2], [1, 0, 0]), dtype=np.float64))
233 array([[0.73105858, 0.5 , 0.88079708],
234 [0.73105858, 0.5 , 0.5 ]])
235 """
236 return 1 / (1 + np.exp(-value))
237
238
239def sigmoid_derivative(value: np.ndarray) -> np.ndarray:

Callers 2

feedforwardMethod · 0.70
predictMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected