未验证 提交 274fe576 编写于 作者: W wawltor 提交者: GitHub

add the activation of sigmoid and layer of Sigmoid (#2380)

* Udpate the doc format for the paddle, test=develop
上级 8f63db58
......@@ -152,4 +152,6 @@ paddle.nn
nn/yolo_box.rst
nn/yolov3_loss.rst
nn/functional/loss/margin_ranking_loss.rst
nn/functional/activation/sigmoid.rst
nn/layer/loss/MarginRankingLoss.rst
nn/layer/activation/Sigmoid.rst
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_nn_functional_activation_sigmoid:
sigmoid
-------
.. autofunction:: paddle.nn.functional.activation.sigmoid
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_nn_layer_activation_Sigmoid:
Sigmoid
-------
.. autoclass:: paddle.nn.layer.activation.Sigmoid
:members:
:inherited-members:
:noindex:
......@@ -19,6 +19,7 @@ paddle.nn
nn_cn/activation_cn.rst
nn_cn/loss_cn.rst
nn_cn/functional_cn.rst
nn_cn/layer_cn.rst
nn_cn/adaptive_pool2d_cn.rst
nn_cn/adaptive_pool3d_cn.rst
nn_cn/add_position_encoding_cn.rst
......
Sigmoid
-------------------------------
**版本升级,文档正在开发中**
......@@ -12,5 +12,6 @@ functional
functional_cn/nll_loss_cn.rst
functional_cn/normalize_cn.rst
functional_cn/margin_ranking_loss_cn.rst
functional_cn/sigmoid_cn.rst
functional_cn/mse_loss_cn.rst
functional_cn/sigmoid_cn.rst
.. _cn_api_nn_functional_sigmoid:
sigmoid
sigmoid
-------------------------------
.. py:function:: paddle.nn.functional.sigmoid(x, name=None)
sigmoid 激活函数。
.. math::
sigmoid激活函数
output = \frac{1}{1 + e^{-x}}
.. math::
out = \frac{1}{1 + e^{-x}}
参数
::::::::
**x** (Tensor) - 输入的 ``Tensor`` ,数据类型为:float32、float64、int32、int64。
**name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。
返回
::::::::
``Tensor``, 经过 ``sigmoid`` 计算后的结果, 和输入 `x` 有一样的shape和数据类型。
参数:
- **x** (Tensor) - 输入的 `Tensor` ,数据类型为:float32、float64。
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。
返回:
- Tensor,对输入x进行sigmoid激活后的Tensor,形状、数据类型与输入x一致。
**代码示例**:
代码示例
:::::::::
.. code-block:: python
import numpy as np
import paddle
import paddle.nn.functional as F
import paddle.nn.functional as F
paddle.disable_static()
x_data = np.array([-0.4, -0.2, 0.1, 0.3])
x = paddle.to_tensor(x_data)
out = F.sigmoid(x)
print(out.numpy())
# [0.40131234 0.450166 0.52497919 0.57444252]
input_data = np.array([1.0, 2.0, 3.0, 4.0]).astype('float32')
x = paddle.to_variable(input_data)
output = F.sigmoid(x)
print(output.numpy()) # [0.7310586, 0.880797, 0.95257413, 0.98201376]
=======================
layer
=======================
.. toctree::
:maxdepth: 1
layer_cn/Sigmoid_cn.rst
.. _cn_api_nn_layer_Sigmoid:
Sigmoid
-------------------------------
.. py:class:: paddle.nn.layer.Sigmoid(name=None)
该接口用于创建一个 ``Sigmoid`` 的可调用类。 这个类可以计算输入 `x` 经过激活函数 `sigmoid` 之后的值。
.. math::
output = \frac{1}{1 + e^{-x}}
参数
::::::::
- **name** (str,可选)- 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。
形状
::::::::
- **x** (Tensor)- N-D tensor, 可以支持的数据类型是float16,float32,float64。
返回
::::::::
返回计算 ``Sigmoid`` 的可调用对象。
代码示例
::::::::
.. code-block:: python
import numpy as np
import paddle
paddle.disable_static()
input_data = np.array([1.0, 2.0, 3.0, 4.0]).astype('float32')
m = paddle.nn.Sigmoid()
x = paddle.to_variable(input_data)
output = m(x)
print(output.numpy()) # [0.7310586, 0.880797, 0.95257413, 0.98201376
import argparse
import sys
import types
import os
import contextlib
def parse_arg():
parser = argparse.ArgumentParser()
parser.add_argument(
'--api_path',
type=str,
default='paddle.nn.functional.l1_loss',
help='the function/class path')
parser.add_argument(
'--is_class',
type=str,
default='False',
help='whether function or class, False means function')
return parser.parse_args()
def add_index(en_doc_review_dir, api_name):
stream = open(en_doc_review_dir + '.rst', 'a')
stream.write(' review_tmp/' + api_name + '.rst\n')
stream.close()
print('add index to ' + en_doc_review_dir + '.rst success')
def add_file(en_doc_review_dir, api_path, is_class=False):
api_path_list = api_path.split('.')
api_name = api_path_list[-1]
api_title = '_'.join(api_path_list[1:])
stream = open(en_doc_review_dir + '/' + api_name + '.rst', 'w')
stream.write('.. _api_' + api_title + ':\n')
stream.write('\n')
stream.write(api_name + '\n')
for i in range(max(9, len(api_name))):
stream.write('-')
stream.write('\n')
stream.write('\n')
if is_class == 'True':
stream.write('.. autoclass:: ' + api_path + '\n')
stream.write(' :members:\n')
stream.write(' :inherited-members:\n')
else:
stream.write('.. autofunction:: ' + api_path + '\n')
stream.write(' :noindex:\n')
stream.close()
print('add' + en_doc_review_dir + '/' + api_name + '.rst success')
def main():
args = parse_arg()
api_path = args.api_path
is_class = args.is_class
api_name = api_path.split('.')[-1]
fluid_doc_path = os.getcwd()
en_doc_review_dir = fluid_doc_path + '/doc/fluid/api/review_tmp'
add_index(en_doc_review_dir, api_name)
add_file(en_doc_review_dir, api_path, is_class)
if __name__ == '__main__':
main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册