# Sigmoid function The Sigmoid function is an [[Activation Functions]] **WARNING**: This function is NOT used as an activation function because it is subject to the [[Vanishing Gradient]] problem. # How it works It takes as input the weighted sum of the inputs (cfr [[Forward Propagation]]) and outputs a number between 0 and 1. When the weighted sum of the inputs is a very large positive number, the output is close to 1. When the weighted sum is a very large negative number, then the output of the neuron is close to zero. The sigmoid function goes smoothly from 0 to 1 and crosses the y axis at 0.5 - ![[20230822170730 sigmoid.png]] - `sigmoid(z) = 1 / 1 + e^-z` - 1 divided by 1 + e exponent minus `z` - If `z` is very large, then `e^-z` will be close to 0, so the result of the sigmoid function will be ~1 - If `z` is very small, ... will be 0 ## Python implementation ```python import math def sigmoid(x): return 1 / (1 + math.exp(-x)) ``` ## Tools - Online calculator: https://www.tinkershop.net/ml/sigmoid_calculator.html