MCPcopy Create free account
hub / github.com/BVLC/caffe / LayerSetUp

Method LayerSetUp

src/caffe/layers/pooling_layer.cpp:14–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12
13template <typename Dtype>
14void PoolingLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
15 const vector<Blob<Dtype>*>& top) {
16 PoolingParameter pool_param = this->layer_param_.pooling_param();
17 if (pool_param.global_pooling()) {
18 CHECK(!(pool_param.has_kernel_size() ||
19 pool_param.has_kernel_h() || pool_param.has_kernel_w()))
20 << "With Global_pooling: true Filter size cannot specified";
21 } else {
22 CHECK(!pool_param.has_kernel_size() !=
23 !(pool_param.has_kernel_h() && pool_param.has_kernel_w()))
24 << "Filter size is kernel_size OR kernel_h and kernel_w; not both";
25 CHECK(pool_param.has_kernel_size() ||
26 (pool_param.has_kernel_h() && pool_param.has_kernel_w()))
27 << "For non-square filters both kernel_h and kernel_w are required.";
28 }
29 CHECK((!pool_param.has_pad() && pool_param.has_pad_h()
30 && pool_param.has_pad_w())
31 || (!pool_param.has_pad_h() && !pool_param.has_pad_w()))
32 << "pad is pad OR pad_h and pad_w are required.";
33 CHECK((!pool_param.has_stride() && pool_param.has_stride_h()
34 && pool_param.has_stride_w())
35 || (!pool_param.has_stride_h() && !pool_param.has_stride_w()))
36 << "Stride is stride OR stride_h and stride_w are required.";
37 global_pooling_ = pool_param.global_pooling();
38 if (global_pooling_) {
39 kernel_h_ = bottom[0]->height();
40 kernel_w_ = bottom[0]->width();
41 } else {
42 if (pool_param.has_kernel_size()) {
43 kernel_h_ = kernel_w_ = pool_param.kernel_size();
44 } else {
45 kernel_h_ = pool_param.kernel_h();
46 kernel_w_ = pool_param.kernel_w();
47 }
48 }
49 CHECK_GT(kernel_h_, 0) << "Filter dimensions cannot be zero.";
50 CHECK_GT(kernel_w_, 0) << "Filter dimensions cannot be zero.";
51 if (!pool_param.has_pad_h()) {
52 pad_h_ = pad_w_ = pool_param.pad();
53 } else {
54 pad_h_ = pool_param.pad_h();
55 pad_w_ = pool_param.pad_w();
56 }
57 if (!pool_param.has_stride_h()) {
58 stride_h_ = stride_w_ = pool_param.stride();
59 } else {
60 stride_h_ = pool_param.stride_h();
61 stride_w_ = pool_param.stride_w();
62 }
63 if (global_pooling_) {
64 CHECK(pad_h_ == 0 && pad_w_ == 0 && stride_h_ == 1 && stride_w_ == 1)
65 << "With Global_pooling: true; only pad = 0 and stride = 1";
66 }
67 if (pad_h_ != 0 || pad_w_ != 0) {
68 CHECK(this->layer_param_.pooling_param().pool()
69 == PoolingParameter_PoolMethod_AVE
70 || this->layer_param_.pooling_param().pool()
71 == PoolingParameter_PoolMethod_MAX)

Callers

nothing calls this directly

Calls 2

heightMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected