From d2de2ee54386500701527450145dd7cb7512a3e4 Mon Sep 17 00:00:00 2001 From: Jonathan L Long Date: Fri, 12 Sep 2014 13:56:38 -0700 Subject: [PATCH] call Reshape in Layer::SetUp Strictly speaking, Reshape doesn't need to be called until the first Forward call; however, much existing code (especially tests) assumes that top blobs will be set up in SetUp, so we may as well do it there. --- include/caffe/layer.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/caffe/layer.hpp b/include/caffe/layer.hpp index 9bd42e7..b05c332 100644 --- a/include/caffe/layer.hpp +++ b/include/caffe/layer.hpp @@ -51,13 +51,15 @@ class Layer { * the allocated but unshaped output blobs, to be shaped by Reshape * * Checks that the number of bottom and top blobs is correct. - * Calls LayerSetUp to do special layer setup for individual layer types. + * Calls LayerSetUp to do special layer setup for individual layer types, + * followed by Reshape to set up sizes of top blobs and internal buffers. * Sets up the loss weight multiplier blobs for any non-zero loss weights. * This method may not be overridden. */ void SetUp(const vector*>& bottom, vector*>* top) { CheckBlobCounts(bottom, *top); LayerSetUp(bottom, top); + Reshape(bottom, top); SetLossWeights(top); } -- 2.7.4