| 7 | |
| 8 | template <typename Dtype> |
| 9 | void MVNLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom, |
| 10 | const vector<Blob<Dtype>*>& top) { |
| 11 | top[0]->Reshape(bottom[0]->num(), bottom[0]->channels(), |
| 12 | bottom[0]->height(), bottom[0]->width()); |
| 13 | mean_.Reshape(bottom[0]->num(), bottom[0]->channels(), |
| 14 | 1, 1); |
| 15 | variance_.Reshape(bottom[0]->num(), bottom[0]->channels(), |
| 16 | 1, 1); |
| 17 | temp_.Reshape(bottom[0]->num(), bottom[0]->channels(), |
| 18 | bottom[0]->height(), bottom[0]->width()); |
| 19 | if ( this->layer_param_.mvn_param().across_channels() ) { |
| 20 | sum_multiplier_.Reshape(1, bottom[0]->channels(), bottom[0]->height(), |
| 21 | bottom[0]->width()); |
| 22 | } else { |
| 23 | sum_multiplier_.Reshape(1, 1, bottom[0]->height(), bottom[0]->width()); |
| 24 | } |
| 25 | Dtype* multiplier_data = sum_multiplier_.mutable_cpu_data(); |
| 26 | caffe_set(sum_multiplier_.count(), Dtype(1), multiplier_data); |
| 27 | eps_ = this->layer_param_.mvn_param().eps(); |
| 28 | } |
| 29 | |
| 30 | template <typename Dtype> |
| 31 | void MVNLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom, |