yifanjiang19 / sppnet-pytorch

A simple Spatial Pyramid Pooling layer which could be added in CNN
Apache License 2.0
329 stars 133 forks source link

why padding in spatial_pyramid_pool function #9

Closed MaybeOjbk closed 4 years ago

MaybeOjbk commented 4 years ago

I'm confused about your spatial_pyramid_pool function, in this function I can't understand why pad? I think [n,c,w,h] - > [n,c,a,a] (a is the number in Variable 'output_num' ) - > [n,-1] ,then feed this to fc. I think the right code is h_wid = math.ceil(previous_conv_size[0]/out_pool_size[i]) w_wid = math.ceil(previous_conv_size[1]/out_pool_size[i]) h_str = math.floor(previous_conv_size[0]/out_pool_size[i]) w_str = math.floor(previous_conv_size[1]/out_pool_size[i]) maxpool = nn.MaxPool2d((h_wid, w_wid), stride=(h_str, w_str))