Skip to content

Commit

Permalink
Merge pull request BVLC#4600 from bwilbertz/fix_scale_layer
Browse files Browse the repository at this point in the history
fix layerSetUp of scale_layer to not add bias blob when already present
  • Loading branch information
jeffdonahue committed Sep 20, 2016
2 parents 25422de + 9bc83e3 commit d208b71
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/caffe/layers/scale_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@ void ScaleLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
bias_bottom_vec_.resize(1);
bias_bottom_vec_[0] = bottom[0];
bias_layer_->SetUp(bias_bottom_vec_, top);
bias_param_id_ = this->blobs_.size();
this->blobs_.resize(bias_param_id_ + 1);
this->blobs_[bias_param_id_] = bias_layer_->blobs()[0];
if (this->blobs_.size() + bottom.size() < 3) {
// case: blobs.size == 1 && bottom.size == 1
// or blobs.size == 0 && bottom.size == 2
bias_param_id_ = this->blobs_.size();
this->blobs_.resize(bias_param_id_ + 1);
this->blobs_[bias_param_id_] = bias_layer_->blobs()[0];
} else {
// bias param already initialized
bias_param_id_ = this->blobs_.size() - 1;
bias_layer_->blobs()[0] = this->blobs_[bias_param_id_];
}
bias_propagate_down_.resize(1, false);
}
this->param_propagate_down_.resize(this->blobs_.size(), true);
Expand Down

0 comments on commit d208b71

Please sign in to comment.