layer initialization
authorYangqing Jia <jiayq84@gmail.com>
Wed, 9 Oct 2013 23:49:50 +0000 (16:49 -0700)
committerYangqing Jia <jiayq84@gmail.com>
Wed, 9 Oct 2013 23:49:50 +0000 (16:49 -0700)
src/caffe/layer.hpp

index 2b73daf..cbfde0c 100644 (file)
@@ -19,7 +19,16 @@ class Layer {
   // to SetUp(), where the dimensions of the bottom blobs are provided to the
   // layer.
   explicit Layer(const LayerParameter& param)
-    : layer_param_(param) {}
+    : layer_param_(param) {
+      // The only thing we do is to copy blobs if there are any.
+      if (layer_param_.blobs_size() > 0) {
+        blobs_.resize(layer_param_.blobs_size());
+        for (int i = 0; i < layer_param_.blobs_size(); ++i) {
+          blobs_[i].reset(new Blob<Dtype>());
+          blobs_[i]->FromProto(layer_param_.blobs(i));
+        }
+      }
+    }
   virtual ~Layer() {}
   // SetUp: your function should implement this.
   virtual void SetUp(const vector<Blob<Dtype>*>& bottom,