Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to INSTANTIATE_CLASS and REGISTER_LAYER_CLASS #2349

Closed
TingLee91 opened this issue Apr 22, 2015 · 2 comments
Closed

How to INSTANTIATE_CLASS and REGISTER_LAYER_CLASS #2349

TingLee91 opened this issue Apr 22, 2015 · 2 comments

Comments

@TingLee91
Copy link

I'm new to Caffe and I have met a big problem about how add my own layer. According to the development wiki I should instantiate and register my layer in my cpp file with the macro provided in layer_factory.hpp with "INSTANTIATE_CLASS(MyAwesomeLayer); REGISTER_LAYER_CLASS(MyAwesome);". I don't quite understand this step. Could anybody explain it in a very explicit way or give me an example. Tks.

@shelhamer
Copy link
Member

Most layer development questions can be answered by referring to the source of current layers, such as the instantiation and registration of InnerProductLayer: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/inner_product_layer.cpp#L126-L127

@shelhamer shelhamer changed the title Question about adding new layer How to INSTANTIATE_CLASS and REGISTER_LAYER_CLASS Apr 27, 2015
@haohao900618
Copy link

I have registered new layer VideoDataLayer:
INSTANTIATE_CLASS(VideoDataLayer);
REGISTER_LAYER_CLASS(VideoData);
but got a error when make all as:
src/caffe/layers/video_data_layer.cpp: In function ‘boost::shared_ptrcaffe::Layer caffe::Creator_VideoDataLayer(const caffe::LayerParameter&) [with Dtype = float]’:
src/caffe/layers/video_data_layer.cpp:490: instantiated from here
src/caffe/layers/video_data_layer.cpp:490: error: cannot allocate an object of abstract type ‘caffe::VideoDataLayer’
./include/caffe/video_data_layer.hpp:41: note: because the following virtual functions are pure within ‘caffe::VideoDataLayer’:
./include/caffe/layer.hpp:100: note: void caffe::Layer::Reshape(const std::vectorcaffe::Blob<Dtype_, std::allocatorcaffe::Blob<Dtype_> >&, const std::vectorcaffe::Blob<Dtype_, std::allocatorcaffe::Blob<Dtype_> >&) [with Dtype = float]
./include/caffe/layer.hpp:304: note: void caffe::Layer::Forward_cpu(const std::vectorcaffe::Blob<Dtype_, std::allocatorcaffe::Blob<Dtype_> >&, const std::vectorcaffe::Blob<Dtype_, std::allocatorcaffe::Blob<Dtype_> >&) [with Dtype = float]
./include/caffe/layer.hpp:320: note: void caffe::Layer::Backward_cpu(const std::vectorcaffe::Blob<Dtype_, std::allocatorcaffe::Blob<Dtype_> >&, const std::vector<bool, std::allocator >&, const std::vectorcaffe::Blob<Dtype_, std::allocatorcaffe::Blob<Dtype_> >&) [with Dtype = float]

Anyone knows what's wrong with the error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants