giagrad.Tensor.tanh#

Tensor.tanh() Tensor[source]#

Applies the Tanh function element-wise. See Tanh.

\[out_i = \frac{e^{data_i} - e^{-data_i}}{e^{data_i} + e^{-data_i}}\]

Examples

>>> t = Tensor.empty(2, 3).uniform(-8, 8)
>>> t
tensor: [[-0.42122853 -3.4285958   7.846644  ]
         [ 0.7483299   6.6553855   3.3439522 ]]
>>> t.tanh()
tensor: [[-0.3979649  -0.9978985   0.9999997 ]
         [ 0.6341515   0.99999666  0.9975113 ]] fn: tanh