RoIPool

class paddle.vision.ops. RoIPool ( output_size, spatial_scale=1.0 ) [source]

This interface is used to construct a callable object of the RoIPool class. Please refer to roi_pool.

Parameters
  • output_size (int or tuple[int, int]) – the pooled output size(h, w), data type is int32. If int, h and w are both equal to output_size.

  • spatial_scale (float, optional) – multiplicative spatial scale factor to translate ROI coords from their input scale to the scale used when pooling. Default: 1.0.

Returns

the pooled feature, 4D-Tensor with the shape of [num_boxes, C, output_size[0], output_size[1]].

Return type

pool_out (Tensor)

Examples

>>> import paddle
>>> from paddle.vision.ops import RoIPool

>>> data = paddle.rand([1, 256, 32, 32])
>>> boxes = paddle.rand([3, 4])
>>> boxes[:, 2] += boxes[:, 0] + 3
>>> boxes[:, 3] += boxes[:, 1] + 4
>>> boxes_num = paddle.to_tensor([3]).astype('int32')
>>> roi_pool = RoIPool(output_size=(4, 3))
>>> pool_out = roi_pool(data, boxes, boxes_num)
>>> print(pool_out.shape)
[3, 256, 4, 3]
forward ( x, boxes, boxes_num )

forward

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments

extra_repr ( )

extra_repr

Extra representation of this layer, you can have custom implementation of your own layer.