Sigmoid函数

1 import numpy as np 
2 import matplotlib.pyplot as plt
3 def sigmoid(x):
4     return 1.0/(1+np.exp(-x))
5 x = np.arange(-10,10,step = 1)# 生成一个numpy数组
6 fig,ax = plt.subplots(figsize=(12,4))
7 #该方法会返回画图对象和坐标对象ax,figsize是设置子图长宽(1200,400)
8 ax.plot(x,sigmoid(x),'r')
9 plt.show()

Sigmoid函数