Skip to content

Commit

Permalink
fix layerSetUp of scale_layer to not add bias blob when already present
Browse files Browse the repository at this point in the history
  • Loading branch information
bwilbertz committed Sep 1, 2016
1 parent 8ba877c commit 9bc83e3
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 9bc83e3

Please sign in to comment.