Description
Judging from the "Development" page on the wiki, it seems that the only way to implement new Caffe layers is to fork the entire Caffe repository and implement the layer in the same manner as the standard layers. Only the actual implementation of the layer is self-contained in its own file, while the declarations go into the standard header files and the layer registration goes into the caffe.proto
file which involves finding an unused ID for the layer.
As far as I can see there are several problems with this approach:
- Researchers routinely develop new kinds of network layers and with the current approach they need to keep all of their custom layers in the same repository. Often a developer will work on several new layers simultaneously and it would make development of several layers much easier if they could be developed in a self-contained manner in separate repositories.
- Developers who implement new types of layers will want to publish them on their own terms or often not publish them at all. If it is necessary to fork Caffe for every addition, then developers will have to always publish a complete fork, which might lead to a proliferation of Caffe forks.
- When a developer of custom layers makes a fork of Caffe they will have to continuously merge new commits back into their own fork. When people publish their own forks and don't continuously merge new code, then there will be many Caffe forks that are out of sync and incompatible with each other. Most obviously, the official Caffe project might assign the protobuffer ID a developer has picked for their layer to a different layer which will create a continuous series of merge conflicts for the layer developer.
- A user who would like to use custom layers created by different developers will have to integrate all of those layers into a single Caffe fork themselves which will routinely create more merge conflicts that the user has to resolve.
Suggestions:
I think it should be possible to design a system by which developers can create new layers completely separately from Caffe, compile them separately and then register their layer in some configuration file to make Caffe aware of its existence. Ideally, this could be done such as to not require recompilation of Caffe every time a new layer is added.
An obvious issue that will have to be solved is that caffe.proto
must dynamically issue layer IDs based on availability. Possibly this could be solved by generating caffe.proto
dynamically from a script and a templating engine to issue dynamic layer IDs. Using this approach a developer would create a short file with all the content that needs to go into caffe.proto
, register this file with Caffe and then Caffe will use a script to stitch all those snippets together and issue a unique ID to every registered layer.
I think separating development of layers from Caffe itself will give a big boost to the community and spur innovation around Caffe and deep learning. It will allow people to develop new layers (and solvers) without needing to deal with the rest of the Caffe code base, then distribute them on their own terms and receiving proper credit for their work. Caffe could publish an index of community developed modules on their website allowing users to easily find modules for any possible need and give developers a venue to showcase their work.