tf.keras.activations.tanh

tf.keras.activations.tanh는 Hyperbolic tangent 함수를 적용합니다.



예제

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['figure.figsize'] = (6, 3)

x = np.linspace(-10, 10, 21)
y = tf.keras.activations.tanh(x).numpy()

print(x)
print(y)

plt.plot(x, y, 'o-')
plt.xlabel('X')
plt.ylabel('Y')
plt.tight_layout()
plt.show()
[-10.  -9.  -8.  -7.  -6.  -5.  -4.  -3.  -2.  -1.   0.   1.   2.   3.
   4.   5.   6.   7.   8.   9.  10.]
[-1.         -0.99999997 -0.99999977 -0.99999834 -0.99998771 -0.9999092
 -0.9993293  -0.99505475 -0.96402758 -0.76159416  0.          0.76159416
  0.96402758  0.99505475  0.9993293   0.9999092   0.99998771  0.99999834
  0.99999977  0.99999997  1.        ]

tf.keras.activations.tanh는 입력값에 Hyperbolic tangent 함수를 적용합니다.

y = tanh(x) = sinh(x)/cosh(x) = ((exp(x) - exp(-x))/(exp(x) + exp(-x)))와 같습니다.


tf.keras.activations.tanh


이전글/다음글

다음글 :