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

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:

主站蜘蛛池模板: 安岳县| 五原县| 滦平县| 莒南县| 瑞丽市| 濮阳县| 鄄城县| 竹山县| 武威市| 辽阳市| 黔西| 武冈市| 和顺县| 花莲市| 防城港市| 苏尼特右旗| 黄浦区| 巩义市| 娄底市| 全南县| 新疆| 保山市| 舒兰市| 扶沟县| 泰安市| 德令哈市| 嘉定区| 衡水市| 宝山区| 闽侯县| 错那县| 个旧市| 广西| 佳木斯市| 海城市| 岳普湖县| 浮山县| 乾安县| 固安县| 文水县| 兴海县|