-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refine sign tanh api, test=develop * Add Tanh, test=develop * fix en, test=develop
- Loading branch information
1 parent
9cfbc97
commit 82a9850
Showing
9 changed files
with
103 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.layer.activation.Tanh | ||
:members: | ||
:inherited-members: | ||
:noindex: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ math | |
math/mm.rst | ||
math/mul.rst | ||
math/pow.rst | ||
math/sign.rst | ||
math/sin.rst | ||
math/sqrt.rst | ||
math/sum.rst | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}` | ||
!DO NOT EDIT THIS FILE MANUALLY! | ||
.. _api_tensor_math_sign: | ||
|
||
sign | ||
------ | ||
|
||
.. autofunction:: paddle.tensor.math.sign | ||
:noindex: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
.. _cn_api_tensor_cn_sign: | ||
.. _cn_api_tensor_sign: | ||
|
||
sign | ||
------------------------------- | ||
:doc_source: paddle.fluid.layers.sign | ||
|
||
.. py:function:: paddle.sign(x, name=None) | ||
此OP对输入x中每个元素进行正负判断,并且输出正负判断值:1代表正,-1代表负,0代表零。 | ||
|
||
参数: | ||
- **x** (Tensor) – 进行正负值判断的多维Tensor,数据类型为 float16, float32或float64。 | ||
- **name** (str,可选) – 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。 | ||
|
||
返回:输出正负号Tensor,数据的shape大小及数据类型和输入 ``x`` 一致。 | ||
|
||
返回类型:Tensor | ||
|
||
**代码示例** | ||
|
||
.. code-block:: python | ||
import numpy as np | ||
import paddle | ||
data = np.array([3.0, 0.0, -2.0, 1.7], dtype='float32') | ||
paddle.disable_static() | ||
x = paddle.to_tensor(data) | ||
out = paddle.sign(x=x) | ||
print(out) # [1.0, 0.0, -1.0, 1.0] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters