- 1. 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 oftype
and the*Blobs()
methods to specify blob number requirements. Omit the*_gpu
declarations if you'll only be implementing CPU code. - 2. Implement your layer in
layers/your_layer.cpp
.SetUp
for initialization: reading parameters, allocating buffers, etc.Forward_cpu
for the function your layer computesBackward_cpu
for its gradient
- 3. (Optional) Implement the GPU versions
Forward_gpu
andBackward_gpu
inlayers/your_layer.cu
. - 4. Add your layer to
proto/caffe.proto
, updating the next available ID. Also declare parameters, if needed, in this file. - 5. Make your layer createable by adding it to
layer_factory.cpp
. - 6. Write tests in
test/test_your_layer.cpp
. Usetest/test_gradient_check_util.hpp
to check that your Forward and Backward implementations are in numerical agreement. - 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 oftype
and the*Blobs()
methods to specify blob number requirements. Omit the*_gpu
declarations if you'll only be implementing CPU code. - Implement your layer in
layers/your_layer.cpp
.SetUp
for initialization: reading parameters, allocating buffers, etc.Forward_cpu
for the function your layer computesBackward_cpu
for its gradient
- (Optional) Implement the GPU versions
Forward_gpu
andBackward_gpu
inlayers/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.hpp
to check that your Forward and Backward implementations are in numerical agreement.
caffe 添加新的网络层
最新推荐文章于 2019-10-24 10:41:32 发布