]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - jacinto-ai/caffe-jacinto.git/blobdiff - src/caffe/net.hpp
a bunch of updates.
[jacinto-ai/caffe-jacinto.git] / src / caffe / net.hpp
index debb59ec74ad594eb7b30ac30941294cdfbde9d2..3ac5fb81382832cb39ad24e00f112bfc1b97cccd 100644 (file)
@@ -8,6 +8,7 @@
 #include <vector>
 
 #include "caffe/blob.hpp"
+#include "caffe/layer.hpp"
 #include "caffe/common.hpp"
 #include "caffe/proto/caffe.pb.h"
 
@@ -23,13 +24,17 @@ class Net {
   Net(const NetParameter& param,
       const vector<Blob<Dtype>* >& bottom);
   ~Net() {}
-  void Forward(const vector<Blob<Dtype>* > & bottom,
-      vector<Blob<Dtype>*>* top);
+  const vector<Blob<Dtype>*>& Forward(const vector<Blob<Dtype>* > & bottom);
   // The network backward should take no input and output, since it solely
   // computes the gradient w.r.t the parameters, and the data has already
   // been provided during the forward pass.
   Dtype Backward();
 
+  Dtype ForwardBackWard(const vector<Blob<Dtype>* > & bottom) {
+    Forward(bottom);
+    return Backward();
+  }
+
   // For an already initialized net, CopyTrainedLayersFrom() copies the already
   // trained layers from another net parameter instance.
   void CopyTrainedLayersFrom(const NetParameter& param);
@@ -37,7 +42,19 @@ class Net {
   void ToProto(NetParameter* param, bool write_diff = false);
 
   // returns the network name.
-  const string& name() { return name_; }
+  inline const string& name() { return name_; }
+  // returns the layer names
+  inline const vector<string>& layer_names() { return layer_names_; }
+  // returns the blob names
+  inline const vector<string>& blob_names() { return blob_names_; }
+  // returns the blobs
+  inline const vector<shared_ptr<Blob<Dtype> > >& blobs() { return blobs_; }
+  // returns the layers
+  inline const vector<shared_ptr<Layer<Dtype> > >& layers() { return layers_; }
+  // returns the parameters
+  vector<shared_ptr<Blob<Dtype> > >& params() { return params_; };
+  // Updates the network
+  void Update();
 
  protected:
   // Individual layers in the net
@@ -45,18 +62,23 @@ class Net {
   vector<string> layer_names_;
   // blobs stores the blobs that store intermediate results between the
   // layers.
-  vector<Blob<Dtype> > blobs_;
+  vector<shared_ptr<Blob<Dtype> > > blobs_;
   vector<string> blob_names_;
-  // bottom_vecs stores the vectors containing the input for each layer, except
-  // for the first layer whose bottom vec is provided by the network's input.
+  // bottom_vecs stores the vectors containing the input for each layer
   vector<vector<Blob<Dtype>*> > bottom_vecs_;
-  // top_vecs stores the vectors containing the output for each layer, except
-  // for the last layer (likewise)
+  vector<vector<int> > bottom_id_vecs_;
+  // top_vecs stores the vectors containing the output for each layer
   vector<vector<Blob<Dtype>*> > top_vecs_;
+  vector<vector<int> > top_id_vecs_;
   // blob indices for the input and the output of the net.
   vector<int> net_input_blob_indices_;
   vector<int> net_output_blob_indices_;
+  vector<Blob<Dtype>*> net_output_blobs_;
   string name_;
+  // The parameters in the network.
+  vector<shared_ptr<Blob<Dtype> > > params_;
+
+  DISABLE_COPY_AND_ASSIGN(Net);
 };