Skip to content

add celu docs #3967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/api/paddle/nn/CELU_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.. _cn_api_nn_CELU:

CELU
-------------------------------
.. py:class:: paddle.nn.CELU(alpha=1.0, name=None)

CELU激活层(CELU Activation Operator)

根据 `Continuously Differentiable Exponential Linear Units <https://arxiv.org/abs/1704.07483>`_ 对输入Tensor中每个元素应用以下计算。

.. math::

CELU(x) = max(0, x) + min(0, \alpha * (e^{x/\alpha} − 1))

其中,:math:`x` 为输入的 Tensor

参数
::::::::::
- alpha (float, 可选) - CELU的alpha值,默认值为1.0。
- name (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。

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

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

.. code-block:: python

import paddle

x = paddle.to_tensor([[-1. ,6.], [1., 15.6]])
m = paddle.nn.CELU(0.2)
out = m(x)
# [[-0.19865242, 6. ],
# [ 1. , 15.60000038]]
2 changes: 2 additions & 0 deletions docs/api/paddle/nn/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Padding层
:header: "API名称", "API功能"


" :ref:`paddle.nn.CELU <cn_api_nn_CELU>` ", "CELU激活层"
" :ref:`paddle.nn.ELU <cn_api_nn_ELU>` ", "ELU激活层"
" :ref:`paddle.nn.GELU <cn_api_nn_GELU>` ", "GELU激活层"
" :ref:`paddle.nn.Hardshrink <cn_api_nn_Hardshrink>` ", "Hardshrink激活层"
Expand Down Expand Up @@ -353,6 +354,7 @@ Padding相关函数
:header: "API名称", "API功能"


" :ref:`paddle.nn.functional.celu <cn_api_nn_cn_celu>` ", "celu激活函数"
" :ref:`paddle.nn.functional.elu <cn_api_nn_cn_elu>` ", "elu激活函数"
" :ref:`paddle.nn.functional.elu_ <cn_api_nn_cn_elu_>` ", "Inplace 版本的 elu API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.nn.functional.gelu <cn_api_nn_cn_gelu>` ", "gelu激活函数"
Expand Down
39 changes: 39 additions & 0 deletions docs/api/paddle/nn/functional/celu_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.. _cn_api_nn_cn_celu:

celu
-------------------------------

.. py:function:: paddle.nn.functional.celu(x, alpha=1.0, name=None)

celu激活层(CELU Activation Operator)

根据 `Continuously Differentiable Exponential Linear Units <https://arxiv.org/abs/1704.07483>`_ 对输入Tensor中每个元素应用以下计算。

.. math::

celu(x) = max(0, x) + min(0, \alpha * (e^{x/\alpha} − 1))

其中,:math:`x` 为输入的 Tensor

参数:
::::::::::
- x (Tensor) - 输入的 ``Tensor`` ,数据类型为:float16、float32、float64。
- alpha (float, 可选) - celu的alpha值,默认值为1.0。
- name (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。

返回
::::::::::
``Tensor`` ,数据类型和形状同 ``x`` 一致。

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

.. code-block:: python

import paddle
import paddle.nn.functional as F

x = paddle.to_tensor([[-1., 6.], [1., 15.6]])
out = F.celu(x, alpha=0.2)
# [[-0.19865242, 6. ],
# [ 1. , 15.60000038]]