From 105ac8ee18c2976d1f0b6d15bd16cbd68745da7c Mon Sep 17 00:00:00 2001 From: PETER_GAO Date: Tue, 12 May 2015 16:58:45 -0700 Subject: [PATCH] DRY up code, add comments --- src/caffe/layers/spp_layer.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/caffe/layers/spp_layer.cpp b/src/caffe/layers/spp_layer.cpp index d23e1b0004e..d13e424d6ab 100644 --- a/src/caffe/layers/spp_layer.cpp +++ b/src/caffe/layers/spp_layer.cpp @@ -22,18 +22,14 @@ LayerParameter SPPLayer::GetPoolingParam(const int pyramid_level, // find padding and kernel size so that the pooling is // performed across the entire image int kernel_h = ceil(bottom_h / static_cast(num_bins)); - int pad_h = 0; + // remainder_h is the min number of pixels that need to be padded + // before entire image is pooled over with the chosen kernel dimension int remainder_h = kernel_h * num_bins - bottom_h; - if (bottom_h % num_bins > 0) { - pad_h = (remainder_h + 1) / 2; - } + int pad_h = (remainder_h + 1) / 2; int kernel_w = ceil(bottom_w / static_cast(num_bins)); - int pad_w = 0; int remainder_w = kernel_w * num_bins - bottom_w; - if (bottom_w % num_bins > 0) { - pad_w = (remainder_w + 1) / 2; - } + int pad_w = (remainder_w + 1) / 2; pooling_param.mutable_pooling_param()->set_pad_h(pad_h); pooling_param.mutable_pooling_param()->set_pad_w(pad_w);