From 209f684c2a2a3b3b4e5270182a50d0e85adc1602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=82=85=E5=89=91=E5=AF=92?= Date: Thu, 17 Nov 2022 17:42:50 +0800 Subject: [PATCH] remove stanh in nn.py under fluid (#47889) --- python/paddle/fluid/layers/nn.py | 46 ------------------- .../tests/unittests/test_activation_op.py | 2 +- 2 files changed, 1 insertion(+), 47 deletions(-) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 1e740ca967..ee85d94e26 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -133,7 +133,6 @@ __all__ = [ 'crop_tensor', 'relu6', 'pow', - 'stanh', 'hard_sigmoid', 'swish', 'prelu', @@ -9936,51 +9935,6 @@ def pow(x, factor=1.0, name=None): return out -@templatedoc() -def stanh(x, scale_a=0.67, scale_b=1.7159, name=None): - """ - stanh activation. - - .. math:: - - 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 :ref:`api_guide_Name`. - - Returns: - A Tensor with the same data type and shape as ``x`` . - - Examples: - .. code-block:: python - - 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) # [1.00616539, 1.49927628, 1.65933108, 1.70390463] - - """ - - if _non_static_mode(): - return _legacy_C_ops.stanh(x, 'scale_a', scale_a, 'scale_b', scale_b) - - check_variable_and_dtype(x, 'x', ['float16', 'float32', 'float64'], 'stanh') - - helper = LayerHelper('stanh', **locals()) - out = helper.create_variable_for_type_inference(dtype=x.dtype) - helper.append_op( - type='stanh', - inputs={'X': x}, - outputs={'Out': out}, - attrs={'scale_a': scale_a, 'scale_b': scale_b}, - ) - return out - - @templatedoc() def hard_sigmoid(x, slope=0.2, offset=0.5, name=None): """ diff --git a/python/paddle/fluid/tests/unittests/test_activation_op.py b/python/paddle/fluid/tests/unittests/test_activation_op.py index ec2adcfcdc..8c4ed1cc1f 100755 --- a/python/paddle/fluid/tests/unittests/test_activation_op.py +++ b/python/paddle/fluid/tests/unittests/test_activation_op.py @@ -2989,7 +2989,7 @@ class TestSTanhAPI(unittest.TestCase): paddle.enable_static() with fluid.program_guard(fluid.Program()): x = fluid.data('X', [10, 12]) - out = fluid.layers.stanh(x, self.scale_a, self.scale_b) + out = paddle.stanh(x, self.scale_a, self.scale_b) exe = fluid.Executor(self.place) res = exe.run(feed={'X': self.x_np}, fetch_list=[out]) out_ref = ref_stanh(self.x_np, self.scale_a, self.scale_b) -- GitLab