From dba693f3281cc975e566f7eba44d21999929430f Mon Sep 17 00:00:00 2001 From: hong19860320 <9973393+hong19860320@users.noreply.github.com> Date: Thu, 26 Sep 2019 16:11:27 +0800 Subject: [PATCH] update cn doc for hard_sigmoid, increment and reverse op (#1382) --- .../api_cn/layers_cn/hard_sigmoid_cn.rst | 30 +++++++---------- doc/fluid/api_cn/layers_cn/increment_cn.rst | 32 +++++-------------- doc/fluid/api_cn/layers_cn/reverse_cn.rst | 27 ++++++---------- 3 files changed, 28 insertions(+), 61 deletions(-) diff --git a/doc/fluid/api_cn/layers_cn/hard_sigmoid_cn.rst b/doc/fluid/api_cn/layers_cn/hard_sigmoid_cn.rst index 78c9bce82..66e17c843 100644 --- a/doc/fluid/api_cn/layers_cn/hard_sigmoid_cn.rst +++ b/doc/fluid/api_cn/layers_cn/hard_sigmoid_cn.rst @@ -5,34 +5,26 @@ hard_sigmoid .. py:function:: paddle.fluid.layers.hard_sigmoid(x, slope=0.2, offset=0.5, name=None) -HardSigmoid激活算子。 - -sigmoid的分段线性逼近(https://arxiv.org/abs/1603.00391),比sigmoid快得多。 +sigmoid的分段线性逼近激活函数,速度比sigmoid快,详细解释参见 https://arxiv.org/abs/1603.00391。 .. math:: - \\out=\max(0,\min(1,slope∗x+shift))\\ - -斜率是正数。偏移量可正可负的。斜率和位移的默认值是根据上面的参考设置的。建议使用默认值。 + \\out=\max(0,\min(1,slope∗x+offset))\\ 参数: - - **x** (Variable) - HardSigmoid operator的输入 - - **slope** (FLOAT|0.2) -斜率 - - **offset** (FLOAT|0.5) - 偏移量 - - **name** (str|None) - 这个层的名称(可选)。如果设置为None,该层将被自动命名。 + - **x** (Variable) - 该OP的输入为多维Tensor。数据类型必须为float32或float64。 + - **slope** (float,可选) - 斜率。值必须为正数,默认值为0.2。 + - **offset** (float,可选) - 偏移量。默认值为0.5。 + - **name** (str, 可选) - 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name`,默认值为None。 +返回:激活后的Tensor,形状、数据类型和 ``x`` 一致。 -**代码示例:** +返回类型:Variable +**代码示例:** .. code-block:: python import paddle.fluid as fluid - x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32") - y = fluid.layers.hard_sigmoid(x, slope=0.3, offset=0.8) - - - - - - + data = fluid.layers.fill_constant(shape=[3, 2], value=0.5, dtype='float32') # [[0.5, 0.5], [0.5, 0.5], [0.5, 0.5]] + result = fluid.layers.hard_sigmoid(data) # [[0.6, 0.6], [0.6, 0.6], [0.6, 0.6]] diff --git a/doc/fluid/api_cn/layers_cn/increment_cn.rst b/doc/fluid/api_cn/layers_cn/increment_cn.rst index 37ea8bcb6..4a5e20b21 100644 --- a/doc/fluid/api_cn/layers_cn/increment_cn.rst +++ b/doc/fluid/api_cn/layers_cn/increment_cn.rst @@ -5,37 +5,21 @@ increment .. py:function:: paddle.fluid.layers.increment(x, value=1.0, in_place=True) - -该函数为输入 ``x`` 增加 ``value`` 大小, ``value`` 即函数中待传入的参数。该函数默认直接在原变量 ``x`` 上进行运算。 - -.. note:: - ``x`` 中元素个数必须为1 +使输入Tensor ``x`` 的数据累加 ``value`` , 该OP通常用于循环次数的计数。 参数: - - **x** (Variable|list) – 含有输入值的张量(tensor) - - **value** (float) – 需要增加在 ``x`` 变量上的值 - - **in_place** (bool) – 判断是否在x变量本身执行操作,True原地执行,False时,返回增加后的副本 + - **x** (Variable) – 元素个数为1的Tensor,数据类型必须为float32,float64,int32,int64。 + - **value** (float,可选) – 需要增加的值,默认为1.0。 + - **in_place** (bool,可选) – 输出Tensor是否和输入Tensor ``x`` 复用同一块内存,默认为True。 -返回: 每个元素增加后的对象 +返回:累加计算后的Tensor,形状、数据类型和 ``x`` 一致。 -返回类型:变量(variable) +返回类型:Variable **代码示例** .. code-block:: python import paddle.fluid as fluid - data = fluid.layers.data(name='data', shape=[1], dtype='float32', - append_batch_size=False) - data = fluid.layers.increment(x=data, value=3.0, in_place=True) - - - - - - - - - - - + counter = fluid.layers.zeros(shape=[1], dtype='float32') # [0.] + fluid.layers.increment(counter) # [1.] diff --git a/doc/fluid/api_cn/layers_cn/reverse_cn.rst b/doc/fluid/api_cn/layers_cn/reverse_cn.rst index 850a4ae7c..0ea877075 100644 --- a/doc/fluid/api_cn/layers_cn/reverse_cn.rst +++ b/doc/fluid/api_cn/layers_cn/reverse_cn.rst @@ -7,31 +7,22 @@ reverse **reverse** -该功能将给定轴上的输入‘x’逆序 +该OP对输入Tensor ``x`` 在指定轴 ``axis`` 上进行数据的逆序操作。 参数: - - **x** (Variable)-预逆序的输入 - - **axis** (int|tuple|list) - 元素逆序排列的轴。如果该参数是一个元组或列表,则对该参数中每个元素值所指定的轴上进行逆序运算。 + - **x** (Variable) - 多维Tensor,类型必须为int32,int64,float32,float64。 + - **axis** (int|tuple|list) - 指定逆序运算的轴,取值范围是[-R, R),R是输入 ``x`` 的Rank, ``axis`` 为负时与 ``axis`` +R 等价。如果 ``axis`` 是一个元组或列表,则在``axis`` 每个元素值所指定的轴上进行逆序运算。 -返回:逆序的张量 +返回:逆序后的Tensor,形状、数据类型和 ``x`` 一致。 -返回类型:变量(Variable) +返回类型:Variable **代码示例**: .. code-block:: python import paddle.fluid as fluid - data = fluid.layers.data(name="data", shape=[4, 8], dtype="float32") - out = fluid.layers.reverse(x=data, axis=0) - # or: - out = fluid.layers.reverse(x=data, axis=[0,1]) - - - - - - - - - + import numpy as np + data = fluid.layers.assign(np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]], dtype='float32')) # [[0., 1., 2.], [3., 4., 5.], [6., 7., 8.]] + result1 = fluid.layers.reverse(data, 0) # [[6., 7., 8.], [3., 4., 5.], [0., 1., 2.]] + result2 = fluid.layers.reverse(data, [0, 1]) # [[8., 7., 6.], [5., 4., 3.], [2., 1., 0.]] -- GitLab