1 #ifndef CAFFEINE_BASE_H_
2 #define CAFFEINE_BASE_H_
4 #include <vector>
5 #include "caffeine/blob.hpp"
6 #include "caffeine/proto/layer_param.pb.h"
8 using std::vector;
10 namespace caffeine {
12 template <typename Dtype>
13 class Layer {
14 public:
15 explicit Layer(const LayerParameter& param)
16 : initialized_(false), layer_param_(param) {};
17 ~Layer();
18 virtual void SetUp(vector<const Blob<Dtype>*>& bottom,
19 vector<Blob<Dtype>*>* top) = 0;
20 virtual void Forward(vector<const Blob<Dtype>*>& bottom,
21 vector<Blob<Dtype>*>* top) = 0;
22 virtual void Predict(vector<const Blob<Dtype>*>& bottom,
23 vector<Blob<Dtype>*>* top) = 0;
24 virtual void Backward(vector<const Blob<Dtype>*>& bottom,
25 vector<Blob<Dtype>*>* top, bool propagate_down) = 0;
26 protected:
27 bool initialized_;
28 // The protobuf that stores the layer parameters
29 LayerParameter layer_param_;
30 // The vector that stores the parameters as a set of blobs.
31 vector<Blob<Dtype> > blobs;
32 }; // class Layer
34 } // namespace caffeine
36 #endif // CAFFEINE_BASE_H_