Skip to content
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

No.18 paddle.nn.GLU易用性提升 中文api文档 #6291

Merged
merged 2 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
27 changes: 27 additions & 0 deletions docs/api/paddle/nn/GLU_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.. _cn_api_paddle_nn_GLU:

GLU
-------------------------------
.. py:class:: paddle.nn.GLU(axis=-1, name=None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把输入也放进去

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个nn.GLU是一个layer,定义这个layer的时候应该是不用放输入的吧,我看其他激活函数也没有放输入

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的


GLU 激活层(GLU Activation Operator)

门控线性单元。输入按照给定的维度二等分,其中第一部分被用作内容,第二部分经过一个 sigmoid 函数之后被用作门限。输出是内容和门限的逐元素乘积。更多细节请参考 `Language Modeling with Gated Convolutional Networks <https://arxiv.org/abs/1612.08083>`_ 。

.. math::
GLU(a, b) = a \otimes \sigma(b)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的数据格式是不是有问题。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


参数
::::::::::
- **axis** (int,可选) - 沿着该轴将输入二等分。:math:`D` 为输入的维数,则 :attr:`axis` 应该在 :math:`[-D, D)` 的范围内。如 :attr:`axis` 为负数,则相当于 :math:`axis + D`,默认值为-1。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

形状
::::::::::
- input:shape[axis]为偶数的 Tensor。
- output: 数据类型与输入一致,在指定的轴上其尺寸减半的 Tensor。

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

COPY-FROM: paddle.nn.GLU
1 change: 1 addition & 0 deletions docs/api/paddle/nn/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Padding 层
" :ref:`paddle.nn.CELU <cn_api_paddle_nn_CELU>` ", "CELU 激活层"
" :ref:`paddle.nn.ELU <cn_api_paddle_nn_ELU>` ", "ELU 激活层"
" :ref:`paddle.nn.GELU <cn_api_paddle_nn_GELU>` ", "GELU 激活层"
" :ref:`paddle.nn.GLU <cn_api_paddle_nn_GLU>` ", "GLU 激活层"
" :ref:`paddle.nn.Hardshrink <cn_api_paddle_nn_Hardshrink>` ", "Hardshrink 激活层"
" :ref:`paddle.nn.Hardsigmoid <cn_api_paddle_nn_Hardsigmoid>` ", "Hardsigmoid 激活层"
" :ref:`paddle.nn.Hardswish <cn_api_paddle_nn_Hardswish>` ", "Hardswish 激活层"
Expand Down