天天看點

TensorFlow - 雙曲正切函數(tanh)

TensorFlow - 雙曲正切函數(tanh)

flyfish

用python 畫一個tanh的圖

TensorFlow - 雙曲正切函數(tanh)
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-, , )

y = np.tanh(x)

plt.plot(x, y, label = "label", color = "red", linewidth = )
plt.xlabel("abscissa")
plt.ylabel("ordinate")
plt.title("tanh Example")
plt.show()
           

linspace的第一個參數表示起始點,第二個參數表示終止點,第三個參數表示數列的個數。

對比sinh,cosh,tanh

TensorFlow - 雙曲正切函數(tanh)

numpy.tanh與下列代碼相同

np.sinh(x) / np.cosh(x)

- 1j * np.tan(1j * x).

tanhu=sinhucoshu

雙曲正切函數(tanh)與tf.sigmoid非常接近,且與後者具有類似的優缺點。tf.sigmoid和tf.tanh的主要差別在于後者的值域為[-1.0,1.0]。

繼續閱讀