From 0b8534f2a456d786fdc7ef2f252409f0ac0bbca3 Mon Sep 17 00:00:00 2001 From: guosheng Date: Mon, 2 Apr 2018 23:35:54 +0800 Subject: [PATCH] Refine python wrapper for pad_op --- doc/fluid/api/layers.rst | 6 ++++++ python/paddle/fluid/layers/nn.py | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/doc/fluid/api/layers.rst b/doc/fluid/api/layers.rst index ae35d8c534..22e6fb13d7 100644 --- a/doc/fluid/api/layers.rst +++ b/doc/fluid/api/layers.rst @@ -494,6 +494,12 @@ reshape .. autofunction:: paddle.fluid.layers.reshape :noindex: +pad +--- + +.. autofunction:: paddle.fluid.layers.pad + :noindex: + scale ----- diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index f96bc6911f..3d13133bf2 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -3380,6 +3380,7 @@ def reshape(x, shape, actual_shape=None, act=None, inplace=True, name=None): Examples: .. code-block:: python + data = fluid.layers.data( name='data', shape=[2, 4, 6], dtype='float32') reshaped = fluid.layers.reshape( @@ -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): """ - Pads a tensor with a constant value given by :attr:pad_value, and the - padded width is specified by :attr:paddings. + Pads a tensor with a constant value given by :attr:`pad_value`, and the + padded width is specified by :attr:`paddings`. - Specifically, the number of values padded before each dimension - :attr:i is indicated by :attr:paddings[i], and the number of values padded - after each dimension :attr:i is indicated by :attr:paddings[i+1]. + Specifically, the number of values padded before the contents of :attr:`x` + in dimension :attr:`i` is indicated by :attr:`paddings[i]`, and the number + 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. @@ -3624,6 +3626,7 @@ def pad(x, paddings, pad_value=0., name=None): Examples: .. code-block:: python + # x is a rank 2 tensor variable. out = fluid.layers.pad( x=x, paddings=[0, 1, 1, 2], pad_value=0.) -- GitLab