ReLU函数
flyfish
ReLU
Leaky ReLU 和 Parametric ReLU (PReLU)
Exponential Linear (ELU, SELU)
ReLU6
ReLU函数
全名是rectified linear unit
修正线性单元
函数的形式为y=max(x,0
小于0时输出一律为0,x大于0时输出就是x。
函数图像是
代码是
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-100, 100, 1000)
y=np.maximum(0, x)
plt.plot(x,y,label="label",color="red",linewidth=2)
plt.xlabel("abscissa")
plt.ylabel("ordinate")
plt.title("LeRU Example")
plt.show()
np.maximum示例
np.maximum([2, 3, 4], [1, 5, 2])
逐个元素比较,输出较大者
输出 array([2, 5, 4])
它的一个平滑解析函数是softplus function,函数形式是 f ( x ) = ln [ 1 + exp ( x ) ] , {\displaystyle f(x)=\ln[1+\exp(x)],} f(x)=ln[1+exp(x)],
或者 f ( x ) = ln ( 1 + e x ) f(x) = \ln(1 + e^x) f(x)=ln(1+ex)
函数图像是
代码是
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-4, 4, 100)
y=np.log(1 + np.exp(1*x))
plt.plot(x,y,label="label",color="red",linewidth=2)
plt.xlabel("abscissa")
plt.ylabel("ordinate")
plt.title("softplus Example")
plt.show()
relu
7 Types of Neural Network Activation Functions: How to Choose?