| 67 | |
| 68 | template <typename Dtype> |
| 69 | void LRNLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom, |
| 70 | const vector<Blob<Dtype>*>& top) { |
| 71 | CHECK_EQ(4, bottom[0]->num_axes()) << "Input must have 4 axes, " |
| 72 | << "corresponding to (num, channels, height, width)"; |
| 73 | num_ = bottom[0]->num(); |
| 74 | channels_ = bottom[0]->channels(); |
| 75 | height_ = bottom[0]->height(); |
| 76 | width_ = bottom[0]->width(); |
| 77 | switch (this->layer_param_.lrn_param().norm_region()) { |
| 78 | case LRNParameter_NormRegion_ACROSS_CHANNELS: |
| 79 | top[0]->Reshape(num_, channels_, height_, width_); |
| 80 | scale_.Reshape(num_, channels_, height_, width_); |
| 81 | break; |
| 82 | case LRNParameter_NormRegion_WITHIN_CHANNEL: |
| 83 | split_layer_->Reshape(bottom, split_top_vec_); |
| 84 | square_layer_->Reshape(square_bottom_vec_, square_top_vec_); |
| 85 | pool_layer_->Reshape(square_top_vec_, pool_top_vec_); |
| 86 | power_layer_->Reshape(pool_top_vec_, power_top_vec_); |
| 87 | product_layer_->Reshape(product_bottom_vec_, top); |
| 88 | break; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | template <typename Dtype> |
| 93 | void LRNLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom, |