未验证 提交 ea4330d2 编写于 作者: Z zhupengyang 提交者: GitHub

add paddle.nn.ReLU and paddle.nn.LogSoftmax doc (#2055)

上级 18a8ec24
......@@ -13,7 +13,7 @@ paddle.nn
nn_cn/diag_embed_cn.rst
nn_cn/interpolate_cn.rst
nn_cn/Linear_cn.rst
nn_cn/log_softmax_cn.rst
nn_cn/LogSoftmax_cn.rst
nn_cn/ReLU_cn.rst
nn_cn/Upsample_cn.rst
nn_cn/activation_cn.rst
......
.. _cn_api_nn_LogSoftmax:
LogSoftmax
-------------------------------
.. py:class:: paddle.nn.LogSoftmax(axis=None)
**LogSoftmax激活层:**
.. math::
\\output = \frac{1}{1 + e^{-input}}\\
参数:
- **axis** (int, 可选) - 指示进行LogSoftmax计算的维度索引,其范围应为 :math:`[-1,rank-1]` ,其中rank是输入变量的秩。默认值:None(与-1效果相同,表示对最后一维做LogSoftmax操作)。
返回:无
**代码示例**
.. code-block:: python
import paddle.fluid as fluid
import paddle.nn as nn
import numpy as np
data = np.array([[[-2.0, 3.0, -4.0, 5.0],
[3.0, -4.0, 5.0, -6.0],
[-7.0, -8.0, 8.0, 9.0]],
[[1.0, -2.0, -3.0, 4.0],
[-5.0, 6.0, 7.0, -8.0],
[6.0, 7.0, 8.0, 9.0]]]).astype('float32')
my_log_softnmax = nn.LogSoftmax()
with fluid.dygraph.guard():
data = fluid.dygraph.to_variable(data)
res = my_log_softnmax(data)
# [[[ -7.1278396 -2.1278396 -9.127839 -0.12783948]
# [ -2.1270514 -9.127051 -0.12705144 -11.127051 ]
# [-16.313261 -17.313261 -1.3132617 -0.31326184]]
# [[ -3.0518122 -6.051812 -7.051812 -0.051812 ]
# [-12.313267 -1.3132664 -0.3132665 -15.313267 ]
# [ -3.4401896 -2.4401896 -1.4401896 -0.44018966]]]
.. _cn_api_nn_ReLU:
ReLU
-------------------------------
**版本升级,文档正在开发中**
.. py:class:: paddle.nn.ReLU(inplace=False)
**ReLU(Rectified Linear Unit)激活层:**
.. math::
\\Out = max(X, 0)\\
其中,:math:`X` 为输入的 Tensor
参数:
- **inplace** (bool,可选)- 如果 ``inplace`` 为 ``True``,则 ``ReLU`` 的输入和输出是同一个变量,否则 ``ReLU`` 的输入和输出是不同的变量。默认值:``False``。请注意,如果 ``ReLU`` 的输入同时是其它OP的输入,则 ``inplace`` 必须为False。
返回:无
**代码示例**
.. code-block:: python
import paddle.fluid as fluid
import paddle.nn as nn
import numpy as np
data = np.array([-2, 0, 1]).astype('float32')
my_relu = nn.ReLU()
with fluid.dygraph.guard():
data = fluid.dygraph.to_variable(data)
res = my_relu(data) # [0, 0, 1]
log
-------------------------------
**版本升级,文档正在开发中**
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册