add deformable psroi pooling#17827
add deformable psroi pooling#17827cjt222 merged 47 commits intoPaddlePaddle:developfrom cjt222:add_deformable_psroi_pooling
Conversation
| AddInput("Input", | ||
| "(Tensor), " | ||
| "the input of Deformable PSROIPooling. " | ||
| "The format of input tensor is NCHW. Where N is batch size, " |
There was a problem hiding this comment.
The shape of input tensor is [N, C, H, W]
| i += blockDim.x * gridDim.x) | ||
|
|
||
| const int CUDA_NUM_THREADS = 1024; | ||
| inline int GET_BLOCKS(const int N) { |
| int x2 = ceil(x); | ||
| int y1 = floor(y); | ||
| int y2 = ceil(y); | ||
| T dist_x = (T)(x - x1); |
| const int group_width, const int part_height, const int part_width, | ||
| const int num_classes, const int channels_each_class, T* top_data, | ||
| T* top_count, int* roi_batch_id_data) { | ||
| CUDA_KERNEL_LOOP(index, count) { |
There was a problem hiding this comment.
please seperate following code with blank lines
There was a problem hiding this comment.
每次改完这行,提交时会被pre-commit重新修正回来,貌似是clang-format的原因
There was a problem hiding this comment.
嗯,是说函数里的代码用空行分一下段,现在连在一起代码看上去会不清晰,下面的函数里也是
| Tensor* top_count = ctx.Output<Tensor>("TopCount"); | ||
| top_count->mutable_data<T>(ctx.GetPlace()); | ||
| PADDLE_ENFORCE_EQ(top_count->dims(), out->dims(), | ||
| "number of rois should be same with number of output"); |
There was a problem hiding this comment.
better to check this in InferShape
python/paddle/fluid/layers/nn.py
Outdated
|
|
||
| Examples: | ||
|
|
||
| input = fluid.layers.data(name="input", |
| from op_test import OpTest | ||
|
|
||
|
|
||
| class TestDeformablePSROIPoolOp(OpTest): |
| AddAttr<int>("no_trans", | ||
| "(int), " | ||
| "whether add offset to get new value or not while roi " | ||
| "pooling, which value is 0 or 1"); |
modify format
… add_deformable_psroi_pooling
add API.spec
heavengate
left a comment
There was a problem hiding this comment.
Please add python api test in python/paddle/fluid/tests/unittests/test_layers.py
run ci again
run ci again
run ci again
run ci again
|
test_layers.py已添加 |
update API.spec
python/paddle/fluid/layers/nn.py
Outdated
| trans (Variable): Offset of features on ROIs while pooling.The format is NCHW, where | ||
| N is number of ROIs, C is number of channels, which indicate the offset distance | ||
| in the x and y directions, H is pooled height, and W is pooled width. | ||
| no_trans(integer): Whether add offset to get new value or not while roi pooling, which |
There was a problem hiding this comment.
- why not bool ?
- 和前面统一,(前面留一个空格。
python/paddle/fluid/layers/nn.py
Outdated
| trans, | ||
| no_trans=0, | ||
| spatial_scale=1.0, | ||
| output_channels=64, |
There was a problem hiding this comment.
why the default output_channels is 64.
There was a problem hiding this comment.
change default value to input channels
python/paddle/fluid/layers/nn.py
Outdated
| output_channels(integer): The number of output channels, which should be less than input channels. | ||
| Deformable roi pooling requires output_channels = input_channels, while | ||
| deformable psroi pooling requires output_channels = input_channels * | ||
| pooled_height * pooled_width. Default: 64. |
python/paddle/fluid/layers/nn.py
Outdated
| Deformable roi pooling requires output_channels = input_channels, while | ||
| deformable psroi pooling requires output_channels = input_channels * | ||
| pooled_height * pooled_width. Default: 64. | ||
| group_size(list): The number of groups which input channels are divided.(eg.number of input channels |
| output_channels=3, | ||
| group_size=(1, 1), | ||
| pooled_height=8, | ||
| pooled_width=8, |
There was a problem hiding this comment.
上面描述:
output_channels = input_channels * pooled_height * pooled_width.
这里例子的设置不是这个关系。
另外,output_channels, pooled_height, pooled_width这3个要同时设置吗? 可以推理得到output_channels吧。
There was a problem hiding this comment.
这个应该需要看用户需求,三个量需要用户同时设置。如果用户想用deformable roi pooling这个功能的话,推理得到就实现不了这个功能了。
There was a problem hiding this comment.
这个例子写的是deformable roi pool的例子,输入和输出的channels一致。
There was a problem hiding this comment.
已将例子改为deformable psroi pooling的形式,另外修正了input_channels = output_channels * pooled_height * pooled_width.的关系。
modify comment
modift comment
modift comment
update API.spec
modify comment
add inference in nn.py
update API.spec
qingqing01
left a comment
There was a problem hiding this comment.
LG for API.
But I see some duplicate code and some irregular code in C++ code.
resolve confict
resolve confict
update API.spec
1、性能测试
测试环境:系统为ubuntu16.04, 显卡为v100
(1) Deformable PSROIPooling 和PSROI Pool对比
输入:
1)input为随机生成的维度为[5, 128, 64, 64]的数据
2)rois为随机生成的16个框,维度为[16, 4],LOD分布为[4,3,2,2,5]
3)trans 为固定维度的[16, 2, 8, 8],值全部为0.5
4)参数设置:
> no_trans=0, spatial_scale=1.0, output_channels=2,
group_size=[1,1], pooled_height=8, pooled_width=8, part_size=[4, 4],
sample_per_part=4, trans_std=0.1
(2) Deformable PSROIPooling和PSROI Pool对比
输入:
1)input为随机生成的维度为[5, 128, 64, 64]的数据
2)rois为随机生成的16个框,维度为[16, 4],LOD分布为[4,3,2,2,5]
3)trans 为固定维度的[16, 2, 8, 8],值全部为0.5
4)参数设置:
>no_trans=1, spatial_scale=1.0, output_channels=128,
group_size=[1,1], pooled_height=8, pooled_width=8, part_size=[4, 4],
sample_per_part=4, trans_std=0.1
2、精度测试

请进入http://agroup.baidu.com/share/md/0f274789bcde46118202deb1fc5b6343 查看
3、API预览文档