激活函数:sigmoid、Tanh、ReLU
生活随笔
收集整理的這篇文章主要介紹了
激活函数:sigmoid、Tanh、ReLU
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
import matplotlib.pyplot as plt
import numpy as np
# 設置字體為中文
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# sigmoid函數圖像
x = np.arange(-10, 10, 0.1)
y = 1. / (1. + np.exp(-x))
plt.plot(x, y)
plt.title(label='sigmoid函數圖像')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
# tanh函數圖像(sigmoid的變形)
x = np.arange(-10, 10, 0.1)
y = 1. / (1. + np.exp(-2*x))
z = 2 * y - 1
plt.plot(x, z)
plt.title(label='tanh函數圖像(sigmoid的變形)')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
# ReLU函數圖像
x = np.arange(-10, 10,0.1)
y = np.where(x<0, 0, x)
plt.plot(x, y)
plt.title(label='ReLU函數圖像')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
總結
以上是生活随笔為你收集整理的激活函数:sigmoid、Tanh、ReLU的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: pytorch:Logistic回归
- 下一篇: 查看进程以及杀进程