megengine.functional.nn.roi_pooling¶
- roi_pooling(inp, rois, output_shape, mode='max', scale=1.0)[源代码]¶
Applies roi pooling on input feature.
- 参数
inp (
Tensor
) – tensor that represents the input feature, (N, C, H, W) images.rois (
Tensor
) – K, 5)` boxes. First column is the index into N. The other 4 columns are xyxy.output_shape (
Union
[int
,tuple
,list
]) – height, width)` of output rois feature.mode (
str
) – max” or “average”, use max/average align just like max/average pooling. Default: “max”scale (
float
) – scale the input boxes by this number. Default: 1.0
- 返回类型
- 返回
K, C, output_shape[0], output_shape[1])
feature of rois.
实际案例
import numpy as np from megengine import tensor import megengine.functional as F np.random.seed(42) inp = tensor(np.random.randn(1, 1, 128, 128)) rois = tensor(np.random.random((4, 5))) y = F.vision.roi_pooling(inp, rois, (2, 2)) print(y.numpy()[0].round(decimals=4))
Outputs:
[[[-0.1383 -0.1383] [-0.5035 -0.5035]]]