Create New Layer

487 views
Skip to first unread message

Roger Trullo

unread,
Jun 8, 2016, 1:44:46 PM6/8/16
to Caffe Users
Hi everyone,
 I am new with Caffe, I have a question; 
if I create a new layer in C++; will it be exposed directly to Python, or I have to do something else.
 Thanks!

Jan

unread,
Jun 9, 2016, 5:28:20 AM6/9/16
to Caffe Users
pycaffe is only a wrapper to libcaffe, which contains all the actual code for the layers, network and solver. In pycaffe all layers are exposed, but only using the generic "Layer" interface (see https://github.com/BVLC/caffe/blob/master/python/caffe/_caffe.cpp#L303-L309).

The proto changes (which you supposedly have if you are developing a new layer, because that layer usually needs some kind of configuration) are "applied" when the protobuf compiler for python is invoked (when you do "make pycaffe"), so you can also create a config for your layer directly in python.

Jan

Roger Trullo

unread,
Jun 9, 2016, 9:55:52 AM6/9/16
to Caffe Users
Ah ok, so if I understand well, I just create the new layer with the "Layer" interface; that is implement the setup, forward and backward methods, add it to the .proto; then make all, and then make pycaffe?
Thanks for your reply!
Roger

Jan

unread,
Jun 10, 2016, 8:07:24 AM6/10/16
to Caffe Users
More or less, yeah. Don't forget the INSTANTIATE_CLASS and REGISTER_LAYER_CLASS macros (usually put at the end of the .cpp) for your layer to register your layer with the layer factory.

You will not even need to add your source files to the Makefile explicitly, since it automatically picks up all .cpp (and .cu) files in the src/caffe/layers subdirectory.

Jan

Roger Trullo

unread,
Jun 10, 2016, 2:56:39 PM6/10/16
to Caffe Users
Thanks!
Message has been deleted

mohsen zarrindel

unread,
Aug 22, 2017, 3:51:41 AM8/22/17
to Caffe Users
Hello

Would you please guide me to create a new layer such as drop connect?
I am new with caffe and python,So I need a step by step guideline

در چهارشنبه 8 ژوئن 2016، ساعت 22:14:46 (UTC+4:30)، Roger نوشته:
Reply all
Reply to author
Forward
0 new messages