激活函数及其梯度
![image-20230511153216403](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834430.png)
1959年科学家对青蛙神经元的机制进行了研究,发现神经元不是对所有的输入都响应,而是只有值大于某个阈值时才会响应,且输出的值是固定的。
科学家借鉴这种机制发明了神经元模型。
![image-20230511153839722](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834432.png)
![image-20230511153806670](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834433.png)
这个函数在z=0处是不连续的,没法求它的导数,无法使用梯度下降进行优化。
为了解决这问题,科学家引入了新的激活函数。
Sigmoid函数(也称Logistic)
![image-20230511154746351](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834434.png)
![image-20230511154830712](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834435.png)
求梯度
![image-20230511154910997](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834436.png)
sigmoid函数存在缺陷,当导数趋近于0时,参数几乎不再更新,这种现象叫梯度弥散。
pytorch中使用
![image-20230511155318516](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834437.png)
Tanh函数
![image-20230511155424655](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834438.png)
求梯度
![image-20230511155535896](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834440.png)
pytorch中使用
![image-20230511155553124](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834441.png)
Relu函数(rectified liner unit 整型的线性单元)
![image-20230511155743132](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834442.png)
求梯度
![image-20230511155814362](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834444.png)
pytorch中使用
![image-20230511155844127](https://gitee.com/drenched-with-snow/pic-go/raw/master/202305251834445.png)