Skip to content

Commit

Permalink
Add Tanh, test=develop
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxicoding committed Aug 21, 2020
1 parent fb08df7 commit 6e8fdde
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/fluid/api/nn/activation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ activation
:maxdepth: 1

activation/Hardshrink.rst
activation/Tanh.rst
13 changes: 13 additions & 0 deletions doc/fluid/api/nn/activation/Tanh.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_nn_activation_Tanh:

Tanh
---------

.. autoclass:: paddle.nn.activation.Tanh
:members:
:inherited-members:
:noindex:

1 change: 1 addition & 0 deletions doc/fluid/api_cn/nn_cn/activation_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ activation
activation_cn/Hardshrink_cn.rst
activation_cn/LeakyReLU_cn.rst
activation_cn/Sigmoid_cn.rst
activation_cn/Tanh_cn.rst
35 changes: 35 additions & 0 deletions doc/fluid/api_cn/nn_cn/activation_cn/Tanh_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.. _cn_api_nn_Tanh:

Tanh
-------------------------------
.. py:class:: paddle.nn.Tanh(name=None)
Tanh激活层

.. math::
Tanh(x) = \frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
参数
::::::::::
- name (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。

形状:
- input: 任意形状的Tensor。
- output: 和input具有相同形状的Tensor。

代码示例
:::::::::

.. code-block:: python
import paddle
import numpy as np
paddle.disable_static()
x = paddle.to_tensor(np.array([-0.4, -0.2, 0.1, 0.3]))
m = paddle.nn.Tanh()
out = m(x)
print(out.numpy())
# [-0.37994896 -0.19737532 0.09966799 0.29131261]

0 comments on commit 6e8fdde

Please sign in to comment.