stanh

paddle. stanh ( x, scale_a=0.67, scale_b=1.7159, name=None ) [source]

stanh activation.

\[out = b * \frac{e^{a * x} - e^{-a * x}}{e^{a * x} + e^{-a * x}}\]
Parameters
  • x (Tensor) – The input Tensor with data type float32, float64.

  • scale_a (float, optional) – The scale factor a of the input. Default is 0.67.

  • scale_b (float, optional) – The scale factor b of the output. Default is 1.7159.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

A Tensor with the same data type and shape as x .

Examples

>>> import paddle

>>> x = paddle.to_tensor([1.0, 2.0, 3.0, 4.0])
>>> out = paddle.stanh(x, scale_a=0.67, scale_b=1.72)
>>> print(out)
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[1.00616539, 1.49927628, 1.65933096, 1.70390463])