官术网_书友最值得收藏!

Sigmoid function

The sigmoid function is a function in mathematics that outputs a value between 0 and 1 for any input:

Here,  and .

Let's understand sigmoid functions better with the help of some simple code. If you do not have Python installed, no problem: we will use an online alternative for now at https://www.jdoodle.com/python-programming-online. We will go through a complete setup from scratch in Chapter 2, Creating a Real-Estate Price Prediction Mobile App. Right now, let's quickly continue with the online alternative.

Once we have the page at https://www.jdoodle.com/python-programming-online loaded, we can go through the code step by step and understand sigmoid functions:

  1. First, let's import the math library so that we can use the exponential function:
from   math   import  e
  1. Next, let's define a function called sigmoid, based on the earlier formula:
def sigmoid ( x ):    
return
1 / ( 1 + e **- x )

  1. Let's take a scenario where our z is very small, -10. Therefore, the function outputs a number that is very small and close to 0:
sigmoid(-10) 
4.539786870243442e-05
  1. If z is very large, such as 10000, then the function will output the maximum possible value, 1:
sigmoid(10000)  
1.0

Therefore, the sigmoid function transforms any value, z, to a value between 0 and 1. When the sigmoid activation function is used on a neuron instead of the traditional perceptron algorithm, we get what is called a sigmoid neuron:

主站蜘蛛池模板: 兰考县| 正阳县| 大悟县| 田阳县| 梧州市| 正镶白旗| 涡阳县| 封丘县| 瓦房店市| 宜黄县| 准格尔旗| 梧州市| 黔江区| 固始县| 六枝特区| 陈巴尔虎旗| 中西区| 会宁县| 长海县| 庐江县| 静安区| 许昌县| 东山县| 仙居县| 武汉市| 慈利县| 垦利县| 彩票| 濮阳县| 乌兰浩特市| 仪征市| 永和县| 巫溪县| 大冶市| 和硕县| 吉木萨尔县| 丁青县| 台州市| 明星| 溧水县| 鸡东县|