prroi_pool

paddle.fluid.layers.prroi_pool(input, rois, spatial_scale=1.0, pooled_height=1, pooled_width=1, batch_roi_nums=None, name=None)[source]

The precise roi pooling implementation for paddle. Reference: https://arxiv.org/pdf/1807.11590.pdf

Parameters
  • input (Variable) – The input of precise roi pooliing.The shape of input tensor is [N,C,H,W]. Where N is batch size,C is number of input channels,H is height of the feature, and W is the width of the feature.

  • rois (Variable) – ROIs (Regions of Interest) to pool over.It should be a 2-D LoDTensor or Tensor of shape (num_rois, 4), the lod level is 1 when it is LoDTensor. The LoD include the rois’s batch index information. If rois is Tensor, its batch index information should be provided by batch_index. Given as [[x1, y1, x2, y2], …], (x1, y1) is the top left coordinates, and (x2, y2) is the bottom right coordinates.

  • spatial_scale (float) – Ratio of input feature map height (or width) to raw image height (or width). Equals the reciprocal of total stride in convolutional layers, Default: 1.0.

  • pooled_height (integer) – The pooled output height. Default: 1.

  • pooled_width (integer) – The pooled output width. Default: 1.

  • batch_roi_nums (Variable) – The number of roi for each image in batch. It should be 1-D Tensor, with shape [N] and dtype int64, where N is the batch size. Default: None. Be note: The lod of input should be empty when batch_roi_nums has values;

  • name (str, default None) – The name of this operation.

Returns

The shape of the returned Tensor is (N, C, pooled_height, pooled_width), with value type float32,float16. N, C denote batch_size and channels of input respectively.

Return type

Variable(Tensor)

Examples

## prroi_pool without batch_roi_num
import paddle.fluid as fluid
x = fluid.data(name='x', shape=[None, 490, 28, 28], dtype='float32')
rois = fluid.data(name='rois', shape=[None, 4], lod_level=1, dtype='float32')
pool_out = fluid.layers.prroi_pool(x, rois, 1.0, 7, 7)

## prroi_pool with batch_roi_num
batchsize=4
x2 = fluid.data(name='x2', shape=[batchsize, 490, 28, 28], dtype='float32')
rois2 = fluid.data(name='rois2', shape=[batchsize, 4], dtype='float32')
batch_rois_num = fluid.data(name='rois_nums', shape=[batchsize], dtype='int64')
pool_out2 = fluid.layers.prroi_pool(x2, rois2, 1.0, 7, 7, batch_roi_nums=batch_rois_num)