import matplotlib.pyplot as plt
import numpy as np
'''
'-' solid line style
'--' dashed line style
'-.' dash-dot line style
':' dotted line style
'''
plt.title("active functions")
x=np.linspace(-10,10,1000)
#simoid
y=np.array([ 1/(1+np.exp(-ele)) for ele in x])
plt.plot(x,y,color="black",linewidth=2.0,linestyle='--',label='sigmoid')
# tan
y1=np.array([(1-np.exp(-2*ele))/(1+np.exp(-2*ele)) for ele in x ])
plt.plot(x,y1,color="red",linewidth=2.0,linestyle=':',label='tan')
# relu
def relu(x):
if x<0:
return 0
else:
return x
y2=np.array([relu(ele) for ele in x])
plt.plot(x,y2,color="blue",linewidth=2.0,linestyle='--',label='relu')
plt.legend()
plt.show()
三种激活函数以及作图
猜你喜欢
转载自blog.csdn.net/huangqihao723/article/details/82662342
今日推荐
周排行