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)
| 9 | |
| 10 | # Sigmoid |
| 11 | def 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 |
no outgoing calls
no test coverage detected