forked from BVLC/caffe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request BVLC#9 from BVLC/master
update from updstream
- Loading branch information
Showing
5 changed files
with
78 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef CAFFE_PARAMETER_LAYER_HPP_ | ||
#define CAFFE_PARAMETER_LAYER_HPP_ | ||
|
||
#include <vector> | ||
|
||
#include "caffe/layer.hpp" | ||
|
||
namespace caffe { | ||
|
||
template <typename Dtype> | ||
class ParameterLayer : public Layer<Dtype> { | ||
public: | ||
explicit ParameterLayer(const LayerParameter& param) | ||
: Layer<Dtype>(param) {} | ||
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom, | ||
const vector<Blob<Dtype>*>& top) { | ||
if (this->blobs_.size() > 0) { | ||
LOG(INFO) << "Skipping parameter initialization"; | ||
} else { | ||
this->blobs_.resize(1); | ||
this->blobs_[0].reset(new Blob<Dtype>()); | ||
this->blobs_[0]->Reshape(this->layer_param_.parameter_param().shape()); | ||
} | ||
top[0]->Reshape(this->layer_param_.parameter_param().shape()); | ||
} | ||
virtual void Reshape(const vector<Blob<Dtype>*>& bottom, | ||
const vector<Blob<Dtype>*>& top) { } | ||
virtual inline const char* type() const { return "Parameter"; } | ||
virtual inline int ExactNumBottomBlobs() const { return 0; } | ||
virtual inline int ExactNumTopBlobs() const { return 1; } | ||
|
||
protected: | ||
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom, | ||
const vector<Blob<Dtype>*>& top) { | ||
top[0]->ShareData(*(this->blobs_[0])); | ||
top[0]->ShareDiff(*(this->blobs_[0])); | ||
} | ||
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top, | ||
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) | ||
{ } | ||
}; | ||
|
||
} // namespace caffe | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "caffe/layers/parameter_layer.hpp" | ||
|
||
namespace caffe { | ||
|
||
INSTANTIATE_CLASS(ParameterLayer); | ||
REGISTER_LAYER_CLASS(Parameter); | ||
|
||
} // namespace caffe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters