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

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:

主站蜘蛛池模板: 华安县| 微山县| 日喀则市| 高州市| 泸定县| 五峰| 绥化市| 土默特左旗| 紫云| 璧山县| 兴义市| 从化市| 岳西县| 同德县| 昭通市| 黄石市| 渑池县| 繁峙县| 仁寿县| 宁国市| 东乡族自治县| 简阳市| 故城县| 南华县| 彰武县| 宁远县| 南郑县| 四平市| 凤山市| 抚顺市| 林州市| 云阳县| 梁河县| 当雄县| 冕宁县| 会宁县| 阳原县| 九江市| 天全县| 从化市| 莒南县|