stanh¶
- paddle. stanh ( x: Tensor, scale_a: float = 0.67, scale_b: float = 1.7159, name: str | None = None ) Tensor [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 bfloat16, float16, float32, float64, uint8, int8, int16, int32, int64.
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|None, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
- Returns
-
A Tensor with the same shape and data type as
x
(integer types are autocasted into float32).
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])