“f5e5baf774b073efbe7f2ce74d6dc93597436bc8”上不存在“develop/doc/howto/dev/new_layer_en.html”
未验证 提交 dba693f3 编写于 作者: H hong19860320 提交者: GitHub

update cn doc for hard_sigmoid, increment and reverse op (#1382)

上级 eaab35cc
...@@ -5,34 +5,26 @@ hard_sigmoid ...@@ -5,34 +5,26 @@ hard_sigmoid
.. py:function:: paddle.fluid.layers.hard_sigmoid(x, slope=0.2, offset=0.5, name=None) .. py:function:: paddle.fluid.layers.hard_sigmoid(x, slope=0.2, offset=0.5, name=None)
HardSigmoid激活算子。 sigmoid的分段线性逼近激活函数,速度比sigmoid快,详细解释参见 https://arxiv.org/abs/1603.00391。
sigmoid的分段线性逼近(https://arxiv.org/abs/1603.00391),比sigmoid快得多。
.. math:: .. math::
\\out=\max(0,\min(1,slope∗x+shift))\\ \\out=\max(0,\min(1,slope∗x+offset))\\
斜率是正数。偏移量可正可负的。斜率和位移的默认值是根据上面的参考设置的。建议使用默认值。
参数: 参数:
- **x** (Variable) - HardSigmoid operator的输入 - **x** (Variable) - 该OP的输入为多维Tensor。数据类型必须为float32或float64。
- **slope** (FLOAT|0.2) -斜率 - **slope** (float,可选) - 斜率。值必须为正数,默认值为0.2。
- **offset** (FLOAT|0.5) - 偏移量 - **offset** (float,可选) - 偏移量。默认值为0.5。
- **name** (str|None) - 这个层的名称(可选)。如果设置为None,该层将被自动命名 - **name** (str, 可选) - 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name`,默认值为None
返回:激活后的Tensor,形状、数据类型和 ``x`` 一致。
**代码示例:** 返回类型:Variable
**代码示例:**
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32") 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]]
y = fluid.layers.hard_sigmoid(x, slope=0.3, offset=0.8) result = fluid.layers.hard_sigmoid(data) # [[0.6, 0.6], [0.6, 0.6], [0.6, 0.6]]
...@@ -5,37 +5,21 @@ increment ...@@ -5,37 +5,21 @@ increment
.. py:function:: paddle.fluid.layers.increment(x, value=1.0, in_place=True) .. py:function:: paddle.fluid.layers.increment(x, value=1.0, in_place=True)
使输入Tensor ``x`` 的数据累加 ``value`` , 该OP通常用于循环次数的计数。
该函数为输入 ``x`` 增加 ``value`` 大小, ``value`` 即函数中待传入的参数。该函数默认直接在原变量 ``x`` 上进行运算。
.. note::
``x`` 中元素个数必须为1
参数: 参数:
- **x** (Variable|list) – 含有输入值的张量(tensor) - **x** (Variable) – 元素个数为1的Tensor,数据类型必须为float32,float64,int32,int64。
- **value** (float) – 需要增加在 ``x`` 变量上的值 - **value** (float,可选) – 需要增加的值,默认为1.0。
- **in_place** (bool) – 判断是否在x变量本身执行操作,True原地执行,False时,返回增加后的副本 - **in_place** (bool,可选) – 输出Tensor是否和输入Tensor ``x`` 复用同一块内存,默认为True。
返回: 每个元素增加后的对象 返回:累加计算后的Tensor,形状、数据类型和 ``x`` 一致。
返回类型:变量(variable) 返回类型:Variable
**代码示例** **代码示例**
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
data = fluid.layers.data(name='data', shape=[1], dtype='float32', counter = fluid.layers.zeros(shape=[1], dtype='float32') # [0.]
append_batch_size=False) fluid.layers.increment(counter) # [1.]
data = fluid.layers.increment(x=data, value=3.0, in_place=True)
...@@ -7,31 +7,22 @@ reverse ...@@ -7,31 +7,22 @@ reverse
**reverse** **reverse**
功能将给定轴上的输入‘x’逆序 OP对输入Tensor ``x`` 在指定轴 ``axis`` 上进行数据的逆序操作。
参数: 参数:
- **x** (Variable)-预逆序的输入 - **x** (Variable) - 多维Tensor,类型必须为int32,int64,float32,float64。
- **axis** (int|tuple|list) - 元素逆序排列的轴。如果该参数是一个元组或列表,则对该参数中每个元素值所指定的轴上进行逆序运算。 - **axis** (int|tuple|list) - 指定逆序运算的轴,取值范围是[-R, R),R是输入 ``x`` 的Rank, ``axis`` 为负时与 ``axis`` +R 等价。如果 ``axis`` 是一个元组或列表,则在``axis`` 每个元素值所指定的轴上进行逆序运算。
返回:逆序的张量 返回:逆序后的Tensor,形状、数据类型和 ``x`` 一致。
返回类型:变量(Variable) 返回类型:Variable
**代码示例**: **代码示例**:
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
data = fluid.layers.data(name="data", shape=[4, 8], dtype="float32") import numpy as np
out = fluid.layers.reverse(x=data, axis=0) 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.]]
# or: result1 = fluid.layers.reverse(data, 0) # [[6., 7., 8.], [3., 4., 5.], [0., 1., 2.]]
out = fluid.layers.reverse(x=data, axis=[0,1]) result2 = fluid.layers.reverse(data, [0, 1]) # [[8., 7., 6.], [5., 4., 3.], [2., 1., 0.]]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册