from matplotlib import pyplot as pl


x=np.arange(-5,5,0.01)

#Relu
y1=np.where(x>0,x,0)
pl.plot(x,y1)
pl.show()

y2=(x+np.abs(x))/2
pl.plot(x,y2)
pl.show()

y3=np.maximum(x,0)
pl.plot(x,y3)
pl.show()


#Sigmoid
y4=1/(1+np.exp(-x))
pl.plot(x,y4)
pl.show()

#Tanh
y5=(np.exp(x)-np.exp(-x))/(np.exp(x)+np.exp(-x))##np.tanh(x)
pl.plot(x,y5)
pl.show()

输出为:
tanh,relu,sigmoid**函数numpy实现tanh,relu,sigmoid**函数numpy实现tanh,relu,sigmoid**函数numpy实现

相关文章:

  • 2021-08-06
  • 2021-12-25
  • 2021-06-18
  • 2021-08-27
  • 2021-04-19
  • 2022-12-23
  • 2021-06-04
  • 2021-06-14
猜你喜欢
  • 2021-06-11
  • 2021-10-21
  • 2021-12-06
  • 2021-08-19
  • 2021-07-27
  • 2022-01-03
  • 2021-09-10
相关资源
相似解决方案