diff options
author | Evan Shelhamer <shelhamer@imaginarynumber.net> | 2015-10-16 16:44:23 -0700 |
---|---|---|
committer | Evan Shelhamer <shelhamer@imaginarynumber.net> | 2016-02-25 13:06:24 -0800 |
commit | 00598ca84e2611cf3bbd363d4920796ce1517ff2 (patch) | |
tree | 9d19edd839d5ad254d2875dd44c9c5e158a06bff /include/caffe | |
parent | fe0f44112a153377ff4c418adefc8c690b872c37 (diff) | |
download | caffeonacl-00598ca84e2611cf3bbd363d4920796ce1517ff2.tar.gz caffeonacl-00598ca84e2611cf3bbd363d4920796ce1517ff2.tar.bz2 caffeonacl-00598ca84e2611cf3bbd363d4920796ce1517ff2.zip |
add InputLayer for Net input
Create an input layer to replace oddball Net `input` fields.
Diffstat (limited to 'include/caffe')
-rw-r--r-- | include/caffe/layers/input_layer.hpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/include/caffe/layers/input_layer.hpp b/include/caffe/layers/input_layer.hpp new file mode 100644 index 00000000..f4472678 --- /dev/null +++ b/include/caffe/layers/input_layer.hpp @@ -0,0 +1,44 @@ +#ifndef CAFFE_INPUT_LAYER_HPP_ +#define CAFFE_INPUT_LAYER_HPP_ + +#include <vector> + +#include "caffe/blob.hpp" +#include "caffe/layer.hpp" +#include "caffe/proto/caffe.pb.h" + +namespace caffe { + +/** + * @brief Provides data to the Net by assigning tops directly. + * + * This data layer is a container that merely holds the data assigned to it; + * forward, backward, and reshape are all no-ops. + */ +template <typename Dtype> +class InputLayer : public Layer<Dtype> { + public: + explicit InputLayer(const LayerParameter& param) + : Layer<Dtype>(param) {} + virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom, + const vector<Blob<Dtype>*>& top); + // Data layers should be shared by multiple solvers in parallel + virtual inline bool ShareInParallel() const { return true; } + // Data layers have no bottoms, so reshaping is trivial. + virtual void Reshape(const vector<Blob<Dtype>*>& bottom, + const vector<Blob<Dtype>*>& top) {} + + virtual inline const char* type() const { return "Input"; } + virtual inline int ExactNumBottomBlobs() const { return 0; } + virtual inline int MinTopBlobs() const { return 1; } + + protected: + virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom, + const vector<Blob<Dtype>*>& top) {} + virtual void Backward_cpu(const vector<Blob<Dtype>*>& top, + const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) {} +}; + +} // namespace caffe + +#endif // CAFFE_INPUT_LAYER_HPP_ |