Skip to content

Commit

Permalink
DRY up code, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
PETER_GAO committed May 12, 2015
1 parent c7e2dfc commit 105ac8e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/caffe/layers/spp_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@ LayerParameter SPPLayer<Dtype>::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<double>(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<double>(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);
Expand Down

0 comments on commit 105ac8e

Please sign in to comment.