提交 0b8534f2 编写于 作者: G guosheng

Refine python wrapper for pad_op

上级 629c9210
...@@ -494,6 +494,12 @@ reshape ...@@ -494,6 +494,12 @@ reshape
.. autofunction:: paddle.fluid.layers.reshape .. autofunction:: paddle.fluid.layers.reshape
:noindex: :noindex:
pad
---
.. autofunction:: paddle.fluid.layers.pad
:noindex:
scale scale
----- -----
......
...@@ -3380,6 +3380,7 @@ def reshape(x, shape, actual_shape=None, act=None, inplace=True, name=None): ...@@ -3380,6 +3380,7 @@ def reshape(x, shape, actual_shape=None, act=None, inplace=True, name=None):
Examples: Examples:
.. code-block:: python .. code-block:: python
data = fluid.layers.data( data = fluid.layers.data(
name='data', shape=[2, 4, 6], dtype='float32') name='data', shape=[2, 4, 6], dtype='float32')
reshaped = fluid.layers.reshape( reshaped = fluid.layers.reshape(
...@@ -3585,12 +3586,13 @@ def lrn(input, n=5, k=1.0, alpha=1e-4, beta=0.75, name=None): ...@@ -3585,12 +3586,13 @@ def lrn(input, n=5, k=1.0, alpha=1e-4, beta=0.75, name=None):
def pad(x, paddings, pad_value=0., name=None): def pad(x, paddings, pad_value=0., name=None):
""" """
Pads a tensor with a constant value given by :attr:pad_value, and the Pads a tensor with a constant value given by :attr:`pad_value`, and the
padded width is specified by :attr:paddings. padded width is specified by :attr:`paddings`.
Specifically, the number of values padded before each dimension Specifically, the number of values padded before the contents of :attr:`x`
:attr:i is indicated by :attr:paddings[i], and the number of values padded in dimension :attr:`i` is indicated by :attr:`paddings[i]`, and the number
after each dimension :attr:i is indicated by :attr:paddings[i+1]. of values padded after the contents of :attr:`x` in dimension :attr:`i` is
indicated by :attr:`paddings[i+1]`.
See below for an example. See below for an example.
...@@ -3624,6 +3626,7 @@ def pad(x, paddings, pad_value=0., name=None): ...@@ -3624,6 +3626,7 @@ def pad(x, paddings, pad_value=0., name=None):
Examples: Examples:
.. code-block:: python .. code-block:: python
# x is a rank 2 tensor variable. # x is a rank 2 tensor variable.
out = fluid.layers.pad( out = fluid.layers.pad(
x=x, paddings=[0, 1, 1, 2], pad_value=0.) x=x, paddings=[0, 1, 1, 2], pad_value=0.)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册