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

Function sigmoid_function

neural_network/simple_neural_network.py:11–21  ·  view source on GitHub ↗

Return the sigmoid function of a float. >>> sigmoid_function(3.5) 0.9706877692486436 >>> sigmoid_function(3.5, True) -8.75

(value: float, deriv: bool = False)

Source from the content-addressed store, hash-verified

9
10# Sigmoid
11def sigmoid_function(value: float, deriv: bool = False) -> float:
12 """Return the sigmoid function of a float.
13
14 >>> sigmoid_function(3.5)
15 0.9706877692486436
16 >>> sigmoid_function(3.5, True)
17 -8.75
18 """
19 if deriv:
20 return value * (1 - value)
21 return 1 / (1 + math.exp(-value))
22
23
24# Initial Value

Callers 1

forward_propagationFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected