1 import matplotlib.pyplot as plt 2 import numpy as np 3 # 生成x数据 4 x = np.linspace(-10,10,100) 5 y = np.tanh(x) 6 plt.plot(x,y) 7 plt.show()