Skip to content

Commit 0b8534f

Browse files
committed
Refine python wrapper for pad_op
1 parent 629c921 commit 0b8534f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

doc/fluid/api/layers.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,12 @@ reshape
494494
.. autofunction:: paddle.fluid.layers.reshape
495495
:noindex:
496496

497+
pad
498+
---
499+
500+
.. autofunction:: paddle.fluid.layers.pad
501+
:noindex:
502+
497503
scale
498504
-----
499505

python/paddle/fluid/layers/nn.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3380,6 +3380,7 @@ def reshape(x, shape, actual_shape=None, act=None, inplace=True, name=None):
33803380
33813381
Examples:
33823382
.. code-block:: python
3383+
33833384
data = fluid.layers.data(
33843385
name='data', shape=[2, 4, 6], dtype='float32')
33853386
reshaped = fluid.layers.reshape(
@@ -3585,12 +3586,13 @@ def lrn(input, n=5, k=1.0, alpha=1e-4, beta=0.75, name=None):
35853586

35863587
def pad(x, paddings, pad_value=0., name=None):
35873588
"""
3588-
Pads a tensor with a constant value given by :attr:pad_value, and the
3589-
padded width is specified by :attr:paddings.
3589+
Pads a tensor with a constant value given by :attr:`pad_value`, and the
3590+
padded width is specified by :attr:`paddings`.
35903591
3591-
Specifically, the number of values padded before each dimension
3592-
:attr:i is indicated by :attr:paddings[i], and the number of values padded
3593-
after each dimension :attr:i is indicated by :attr:paddings[i+1].
3592+
Specifically, the number of values padded before the contents of :attr:`x`
3593+
in dimension :attr:`i` is indicated by :attr:`paddings[i]`, and the number
3594+
of values padded after the contents of :attr:`x` in dimension :attr:`i` is
3595+
indicated by :attr:`paddings[i+1]`.
35943596
35953597
See below for an example.
35963598
@@ -3624,6 +3626,7 @@ def pad(x, paddings, pad_value=0., name=None):
36243626
36253627
Examples:
36263628
.. code-block:: python
3629+
36273630
# x is a rank 2 tensor variable.
36283631
out = fluid.layers.pad(
36293632
x=x, paddings=[0, 1, 1, 2], pad_value=0.)

0 commit comments

Comments
 (0)