Skip to content

Commit 3e34c97

Browse files
committed
improved the documentation for the sequence_pool function
1 parent 674bd83 commit 3e34c97

File tree

1 file changed

+13
-9
lines changed
  • python/paddle/fluid/layers

1 file changed

+13
-9
lines changed

python/paddle/fluid/layers/nn.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,8 @@ def sequence_pool(input, pool_type):
13291329
sqrt : out.data = [2.82, 6.93, 4.24], where 2.82=(1+3)/sqrt(2),
13301330
6.93=(2+4+6)/sqrt(3), 4.24=(5+1)/sqrt(2)
13311331
max : out.data = [3, 6, 5], where 3=max(1,3), 6=max(2,4,6), 5=max(5,1)
1332+
last : out.data = [3, 6, 1], where 3=last(1,3), 6=last(2,4,6), 1=last(5,1)
1333+
first : out.data = [1, 2, 5], where 1=first(1,3), 2=first(2,4,6), 5=first(5,1)
13321334
13331335
Args:
13341336
input(variable): The input variable which is a LoDTensor.
@@ -1348,6 +1350,8 @@ def sequence_pool(input, pool_type):
13481350
sum_x = fluid.layers.sequence_pool(input=x, pool_type='sum')
13491351
sqrt_x = fluid.layers.sequence_pool(input=x, pool_type='sqrt')
13501352
max_x = fluid.layers.sequence_pool(input=x, pool_type='max')
1353+
last_x = fluid.layers.sequence_pool(input=x, pool_type='last')
1354+
first_x = fluid.layers.sequence_pool(input=x, pool_type='first')
13511355
"""
13521356
helper = LayerHelper('sequence_pool', **locals())
13531357
dtype = helper.input_dtype()
@@ -3769,22 +3773,22 @@ def label_smooth(label,
37693773

37703774
def roi_pool(input, rois, pooled_height=1, pooled_width=1, spatial_scale=1.0):
37713775
"""
3772-
Region of interest pooling (also known as RoI pooling) is to perform
3776+
Region of interest pooling (also known as RoI pooling) is to perform
37733777
is to perform max pooling on inputs of nonuniform sizes to obtain
37743778
fixed-size feature maps (e.g. 7*7).
3775-
The operator has three steps:
3776-
1. Dividing each region proposal into equal-sized sections with
3777-
the pooled_width and pooled_height
3778-
2. Finding the largest value in each section
3779+
The operator has three steps:
3780+
1. Dividing each region proposal into equal-sized sections with
3781+
the pooled_width and pooled_height
3782+
2. Finding the largest value in each section
37793783
3. Copying these max values to the output buffer
37803784
37813785
Args:
37823786
input (Variable): The input for ROI pooling.
37833787
rois (Variable): ROIs (Regions of Interest) to pool over. It should
37843788
be a 2-D one level LoTensor of shape [num_rois, 4].
37853789
The layout is [x1, y1, x2, y2], where (x1, y1)
3786-
is the top left coordinates, and (x2, y2) is the
3787-
bottom right coordinates. The num_rois is the
3790+
is the top left coordinates, and (x2, y2) is the
3791+
bottom right coordinates. The num_rois is the
37883792
total number of ROIs in this batch data.
37893793
pooled_height (integer): The pooled output height. Default: 1
37903794
pooled_width (integer): The pooled output width. Default: 1
@@ -3793,11 +3797,11 @@ def roi_pool(input, rois, pooled_height=1, pooled_width=1, spatial_scale=1.0):
37933797
to the scale used when pooling. Default: 1.0
37943798
37953799
Returns:
3796-
pool_out (Variable): The output is a 4-D tensor of the shape
3800+
pool_out (Variable): The output is a 4-D tensor of the shape
37973801
(num_rois, channels, pooled_h, pooled_w).
37983802
37993803
Examples:
3800-
pool_out = fluid.layers.roi_pool(input=x, rois=rois, 7, 7, 1.0)
3804+
pool_out = fluid.layers.roi_pool(input=x, rois=rois, 7, 7, 1.0)
38013805
"""
38023806
helper = LayerHelper('roi_pool', **locals())
38033807
dtype = helper.input_dtype()

0 commit comments

Comments
 (0)