Search code examples
machine-learningneural-networkdeep-learningcaffegradient-descent

Creating new layer in Caffe


I use caffe for my deep learning. To create a new layer for caffe, I need to

(1)add layer to proto/caffe.proto to update the next available ID

(2)make layer createable by adding it to layer_factory.cpp

My queries are what is the purpose new ID in caffe.proto and the functionality of createable in layer_factory.cpp.

There are some layers not included as createable in layer_factory.cpp. What is the difference between those layers included and not included in layer_factory.cpp.


Solution

  • If you want to add a new layer to caffe, please follow the instruction in wiki/Development.
    You'll see there that you don't need to change layer_factory.cpp, but rather add two macros INSTANTIATE_CLASS and REGISTER_LAYER_CLASS in your cpp file.

    Regarding caffe.proto: you only need to change there if you want your layer to have a specific my_layer_param message. If your layer re-use params of existing layers, you don't need to change caffe.proto at all.