stanh

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

STanh Activation Operator.

$$out = b * \frac{e^{a * x} - e^{-a * x}}{e^{a * x} + e^{-a * x}}$$

Parameters
  • x (Variable) – Input of STanh operator. A LoDTensor or Tensor with type float32, float64

  • scale_a (FLOAT|2.0 / 3.0) – The scale parameter of a for the input.

  • scale_b (FLOAT|1.7159) – The scale parameter of b for the input

  • name (str|None) – A name for this layer(optional). If set None, the layer will be named automatically.

Returns

Output of STanh operator. A Tensor with type float32.

Return type

output(Variable)

Examples

import paddle.fluid as fluid
import numpy as np
data = fluid.data(name="input", shape=[-1, 3])
result = fluid.layers.stanh(data,scale_a=0.67, scale_b=1.72)
place = fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
x = np.random.random(size=(3, 3)).astype('float32')
output= exe.run(feed={"input": x},
             fetch_list=[result])
print(output)

#[array([[0.626466  , 0.89842904, 0.7501062 ],
#       [0.25147712, 0.7484996 , 0.22902708],
#       [0.62705994, 0.23110689, 0.56902856]], dtype=float32)]