]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - jacinto-ai/caffe-jacinto.git/blob - src/caffe/net.hpp
softmax layer, test to be written
[jacinto-ai/caffe-jacinto.git] / src / caffe / net.hpp
1 // Copyright 2013 Yangqing Jia
3 #ifndef CAFFE_NET_HPP_
4 #define CAFFE_NET_HPP_
6 #include <map>
7 #include <string>
8 #include <vector>
10 #include "caffe/blob.hpp"
11 #include "caffe/common.hpp"
12 #include "caffe/proto/caffe.pb.h"
14 using std::map;
15 using std::vector;
16 using std::string;
18 namespace caffe {
20 template <typename Dtype>
21 class Net {
22  public:
23   Net(const NetParameter& param,
24       const vector<Blob<Dtype>* >& bottom);
25   ~Net() {}
26   void Forward(const vector<Blob<Dtype>* > & bottom,
27       vector<Blob<Dtype>*>* top);
28   // The network backward should take no input and output, since it solely
29   // computes the gradient w.r.t the parameters, and the data has already
30   // been provided during the forward pass.
31   Dtype Backward();
33   // For an already initialized net, CopyTrainedLayersFrom() copies the already
34   // trained layers from another net parameter instance.
35   void CopyTrainedLayersFrom(const NetParameter& param);
36   // Writes the net to a proto.
37   void ToProto(NetParameter* param, bool write_diff = false);
39   // returns the network name.
40   const string& name() { return name_; }
42  protected:
43   // Individual layers in the net
44   vector<shared_ptr<Layer<Dtype> > > layers_;
45   vector<string> layer_names_;
46   // blobs stores the blobs that store intermediate results between the
47   // layers.
48   vector<Blob<Dtype> > blobs_;
49   vector<string> blob_names_;
50   // bottom_vecs stores the vectors containing the input for each layer, except
51   // for the first layer whose bottom vec is provided by the network's input.
52   vector<vector<Blob<Dtype>*> > bottom_vecs_;
53   // top_vecs stores the vectors containing the output for each layer, except
54   // for the last layer (likewise)
55   vector<vector<Blob<Dtype>*> > top_vecs_;
56   // blob indices for the input and the output of the net.
57   vector<int> net_input_blob_indices_;
58   vector<int> net_output_blob_indices_;
59   string name_;
60 };
63 }  // namespace caffe
65 #endif  // CAFFE_NET_HPP_