oneflow.nn.Tanh

class oneflow.nn.Tanh

This operator computes the hyperbolic tangent value of Tensor.

The equation is:

\[out = \frac{e^x-e^{-x}}{e^x+e^{-x}}\]
Parameters

input (oneflow.Tensor) – A Tensor

Returns

The result Tensor

Return type

oneflow.Tensor

For example:

>>> import numpy as np
>>> import oneflow as flow

>>> x = np.array([-1, 0, 1]).astype(np.float32)
>>> input = flow.Tensor(x)
>>> tanh = flow.nn.Tanh()
>>> out = tanh(input)
>>> out
tensor([-0.7616,  0.0000,  0.7616], dtype=oneflow.float32)