From 1a2046a3448d6e6fada19561a3f1722f450ae945 Mon Sep 17 00:00:00 2001 From: Yangqing Jia Date: Wed, 9 Oct 2013 16:49:50 -0700 Subject: [PATCH] layer initialization --- src/caffe/layer.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/caffe/layer.hpp b/src/caffe/layer.hpp index 2b73daf..cbfde0c 100644 --- a/src/caffe/layer.hpp +++ b/src/caffe/layer.hpp @@ -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()); + blobs_[i]->FromProto(layer_param_.blobs(i)); + } + } + } virtual ~Layer() {} // SetUp: your function should implement this. virtual void SetUp(const vector*>& bottom, -- 2.7.4