直接上代码:
1 import numpy as np 2 import matplotlib.pyplot as plt 3 from pylab import * 4 5 mpl.rcParams['font.sans-serif'] = ['SimHei'] 6 def sigmoid(t): 7 return 1. / (1. + np.exp(-t)) 8 x_plot = np.linspace(-10., 10., 5000) 9 y_plot = sigmoid(x_plot) 10 plt.plot(x_plot, y_plot) 11 plt.show()