batch_normalization icon indicating copy to clipboard operation
batch_normalization copied to clipboard

Do you plan to do a Pull Request on this?

Open forresti opened this issue 9 years ago • 4 comments

It would be great to get batch normalization into the main branch of Caffe!

forresti avatar Jun 09 '15 18:06 forresti

Sorry to barge in, I am having trouble with adding this layer in the newer version of caffe. I do as the wiki (s://github.com/BVLC/caffe/wiki/Development) tells me and I end up with this error:

src/caffe/layers/bn_layer.cpp: In instantiation of ‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::Creator_BNLayer(const caffe::LayerParameter&) [with Dtype = float]’:
src/caffe/layers/bn_layer.cpp:276:2:   required from here
./include/caffe/layer_factory.hpp:121:67: error: cannot allocate an object of abstract type ‘caffe::BNLayer<float>’
     return shared_ptr<Layer<Dtype> >(new type##Layer<Dtype>(param));           \
                                                                   ^
src/caffe/layers/bn_layer.cpp:276:2: note: in expansion of macro ‘REGISTER_LAYER_CLASS’
  REGISTER_LAYER_CLASS(BN);
  ^
In file included from src/caffe/layers/bn_layer.cpp:4:0:
./include/caffe/common_layers.hpp:408:7: note:   because the following virtual functions are pure within ‘caffe::BNLayer<float>’:
 class BNLayer : public Layer<Dtype> {
       ^
In file included from ./include/caffe/data_layers.hpp:16:0,
                 from ./include/caffe/common_layers.hpp:10,
                 from src/caffe/layers/bn_layer.cpp:4:
./include/caffe/layer.hpp:100:16: note:     void caffe::Layer<Dtype>::Reshape(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = float]
   virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
                ^
./include/caffe/layer.hpp:304:16: note:     void caffe::Layer<Dtype>::Forward_cpu(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = float]
   virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
                ^
./include/caffe/layer.hpp:320:16: note:     void caffe::Layer<Dtype>::Backward_cpu(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<bool>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = float]
   virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
                ^
In file included from ./include/caffe/layer.hpp:10:0,
                 from ./include/caffe/data_layers.hpp:16,
                 from ./include/caffe/common_layers.hpp:10,
                 from src/caffe/layers/bn_layer.cpp:4:
src/caffe/layers/bn_layer.cpp: In instantiation of ‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::Creator_BNLayer(const caffe::LayerParameter&) [with Dtype = double]’:
src/caffe/layers/bn_layer.cpp:276:2:   required from here
./include/caffe/layer_factory.hpp:121:67: error: cannot allocate an object of abstract type ‘caffe::BNLayer<double>’
     return shared_ptr<Layer<Dtype> >(new type##Layer<Dtype>(param));           \
                                                                   ^
src/caffe/layers/bn_layer.cpp:276:2: note: in expansion of macro ‘REGISTER_LAYER_CLASS’
  REGISTER_LAYER_CLASS(BN);
  ^
In file included from src/caffe/layers/bn_layer.cpp:4:0:
./include/caffe/common_layers.hpp:408:7: note:   because the following virtual functions are pure within ‘caffe::BNLayer<double>’:
 class BNLayer : public Layer<Dtype> {
       ^
In file included from ./include/caffe/data_layers.hpp:16:0,
                 from ./include/caffe/common_layers.hpp:10,
                 from src/caffe/layers/bn_layer.cpp:4:
./include/caffe/layer.hpp:100:16: note:     void caffe::Layer<Dtype>::Reshape(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = double]
   virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
                ^
./include/caffe/layer.hpp:304:16: note:     void caffe::Layer<Dtype>::Forward_cpu(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = double]
   virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
                ^
./include/caffe/layer.hpp:320:16: note:     void caffe::Layer<Dtype>::Backward_cpu(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<bool>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = double]
   virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,

Any ideas as to what's going on ?

swamiviv avatar Sep 24 '15 22:09 swamiviv

Were you able to resolve this? I have the same issue. Thanks in advance.

siddharthachandra avatar Oct 28 '15 13:10 siddharthachandra

same here !!!!!!!!!!!!! Actually I have created a layer "example_layer.cpp" and after doing all the appropriate steps I came up with this error

In instantiation of ‘boost::shared_ptrcaffe::Layer<Dtype > caffe::GetExampleLayer(const caffe::LayerParameter&) [with Dtype = double]’: src/caffe/layer_factory.cpp:229:1: required from here src/caffe/layer_factory.cpp:222:74: error: cannot allocate an object of abstract type ‘caffe::ExampleLayer’ return shared_ptr<Layer<Dtype> >(new ExampleLayer<Dtype>(param));

In layer_factory.cpp, I added:

template <typename Dtype> shared_ptr<Layer<Dtype> > GetExampleLayer (const LayerParameter& param){ return shared_ptr<Layer<Dtype> >(new ExampleLayer<Dtype>(param)); }

REGISTER_LAYER_CREATOR(Example, GetExampleLayer);

Elpidam avatar Dec 01 '15 18:12 Elpidam

Did any of you guys manage to resolve this? This has been plaguing me all day!

96imranahmed avatar Aug 06 '16 21:08 96imranahmed