import numpy as np import matplotlib.pyplot as plt from pynverse import inversefunc def my_tah(x): sigma = -0.1 # base_tah = np.tanh(x) # base_tah = (2/(1+np.exp(-2*x))) - 1 base_tah = (2 / (1 + np.exp(sigma * x))) - 1 result = 5*base_tah return result if __name__ == '__main__': a = np.linspace(-200,200,500) tah_a = my_tah(a) # 自定义的tanh变种函数 tah_inverse = inversefunc(my_tah,tah_a) # 反函数还原 plt.subplot(121) plt.plot(a ,tah_a) plt.subplot(122) plt.plot(a, tah_inverse) # plt.axis('off') plt.show()
标签:__,plt,python,base,还原,np,import,tah,反函数 From: https://www.cnblogs.com/cxhzy/p/16904765.html