For example, now to add a vision layer, called Ly_layer: (generally named the first letter uppercase, the remaining lowercase.) )
1, which type of layer (a total of five species:common_layer, Data_layer, Loss_layer, Neuron_layer, Vision_layer ), open which HPP file (caffe-master/include/caffe/), open vision_layers.hpp here, and then add the definition of the layer yourself, or copy it directly Convolution_ Layer's related code to modify the class name and constructor names to Ly_layer, without the GPU, remove the *_gpu declaration.
2, to achieve their own Layer, write ly_layer.cpp, add to Src/caffe/layers, the main implementation of Setup, FORWARD_CPU, backward_cpu.
3. If GPU implementations are required, FORWARD_GPU and BACKWARD_GPU are implemented in LY_LAYER.CU (also in/src/caffe/ayers).
4, modify Src/caffe/proto/caffe.proto, good to Layertype, add ly, and update ID, if the layer has parameters, add Lyparameter class.
5, add the response code in Src/caffe/layer_factory.cpp (a bunch of if...else ... )。
6, write a test_ly_layer.cpp in the src/caffe/test, use the INCLUDE/CAFFE/TEST/TEST_GRADIENT_CHECK_UTIL.HPP to check the forward and backward propagation is correct.
(. hpp header file;. CPP execution file)
Add a new layer to the Caffe