This repository was archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 485
Development
shelhamer edited this page Oct 2, 2014
·
24 revisions
- Add a class declaration for your layer to the appropriate one of
common_layers.hpp,data_layers.hpp,loss_layers.hpp,neuron_layers.hpp, orvision_layers.hpp. Include an inline implementation oftypeand the*Blobs()methods to specify blob number requirements. Omit the*_gpudeclarations if you'll only be implementing CPU code. - Implement your layer in
layers/your_layer.cpp.
- (optional)
LayerSetUpfor one-time initialization: reading parameters, fixed-size allocations, etc. -
Reshapefor computing the sizes of top blobs, allocating buffers, and any other work that depends on the shapes of bottom blobs -
Forward_cpufor the function your layer computes -
Backward_cpufor its gradient
- (Optional) Implement the GPU versions
Forward_gpuandBackward_gpuinlayers/your_layer.cu. - Add your layer to
proto/caffe.proto, updating the next available ID. Also declare parameters, if needed, in this file. - Make your layer createable by adding it to
layer_factory.cpp. - Write tests in
test/test_your_layer.cpp. Usetest/test_gradient_check_util.hppto check that your Forward and Backward implementations are in numerical agreement.