Skip to content

Commit

Permalink
fix: initialize object members on LayerSetUp
Browse files Browse the repository at this point in the history
  • Loading branch information
ankalinin committed Sep 7, 2016
1 parent 4ebe7ae commit a04757a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/caffe/layers/mkldnn_batch_norm_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ void MKLDNNBatchNormLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom

Layer<Dtype>::LayerSetUp(bottom, top);

channels_ = bottom[0]->channels();
height_ = bottom[0]->height();
width_ = bottom[0]->width();
num_ = bottom[0]->num();

eps_ = this->layer_param_.batch_norm_param().eps();
use_weight_bias_ = this->layer_param_.batch_norm_param().use_weight_bias();
bias_term_ = this->layer_param_.batch_norm_param().bias_term();
Expand All @@ -33,6 +38,7 @@ void MKLDNNBatchNormLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom
// Initialize scale and shift
vector<int> scaleshift_shape(1);
scaleshift_shape[0] = channels_;
VLOG(1) << "MKLDNNBatchNormLayer<Dtype>::LayerSetUp: channels_ = " << channels_;

this->blobs_[0].reset(new Blob<Dtype>(scaleshift_shape));
FillerParameter filler_param(this->layer_param_.batch_norm_param().filler());
Expand All @@ -41,6 +47,7 @@ void MKLDNNBatchNormLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom
filler_param.set_value(1);
}
shared_ptr<Filler<Dtype> > filler(GetFiller<Dtype>(filler_param));
VLOG(1) << "MKLDNNBatchNormLayer<Dtype>::LayerSetUp: scaleshift " << __LINE__ << ":" << this->layer_param_.name();
filler->Fill(this->blobs_[0].get());

if ( bias_term_ ) {
Expand All @@ -51,6 +58,7 @@ void MKLDNNBatchNormLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom
bias_filler_param.set_value(0);
}
shared_ptr<Filler<Dtype> > bias_filler(GetFiller<Dtype>(bias_filler_param));
VLOG(1) << "MKLDNNBatchNormLayer<Dtype>::LayerSetUp: bias " << __LINE__ << ":" << this->layer_param_.name();
bias_filler->Fill(this->blobs_[1].get());
}
}
Expand Down

0 comments on commit a04757a

Please sign in to comment.