spp_net 在caffe上的实现

caffe源码地址:https://github.com/BVLC/caffe

caffe上有spp_net 网络实现的源码,路径是caffe/src/caffe/layers/spp_layer.cpp,琢磨下,看能不能直接在caffe上跑起来。

http://blog.csdn.net/mao_kun/article/details/50533788这个帖子里有对这个cpp文件很详细的注释。

根据https://github.com/BVLC/caffe/wiki/Development中如何Developing new layers一一比对

1.Add a class declaration for your layer to include/caffe/layers/your_layer.hpp

master/caffe/include/caffe/layers/spp_layer.hpp

2.Implement your layer in src/caffe/layers/your_layer.cpp.

master/caffe/src/caffe/layers/spp_layer.cpp

3.(Optional) Implement the GPU versions Forward_gpu and Backward_gpu in layers/your_layer.cu.

caffe中没有实现相对应的spp_layer.cu文件

4. If needed, declare parameters in proto/caffe.proto, using (and then incrementing) the "next available layer-specific ID" declared in a comment above message LayerParameter

即要在caffe.proto中增加spp_layer的定义,在caffe.proto中查找,有关于spp_layer的定义:


optional SPPParameter spp_param = 132;

message SPPParameter {
  enum PoolMethod {
    MAX = 0;
    AVE = 1;
    STOCHASTIC = 2;
  }
  optional uint32 pyramid_height = 1;
  optional PoolMethod pool = 2 [default = MAX]; // The pooling method
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 6 [default = DEFAULT];
}

5.Instantiate and register your layer in your cpp file with the macro provided inlayer_factory.hpp.
利用layer_factory.hpp中提供的宏函数对你的层进行实例化和注册。


master/caffe/src/caffe/layers/spp_layer.cpp中就有对spp层的实例化和注册的语句。
INSTANTIATE_CLASS(SPPLayer);
REGISTER_LAYER_CLASS(SPP);


  • Optionally, you can also register a Creator if your layer has multiple engines.
  • For an example on how to define a creator function and register it, see GetConvolutionLayer incaffe/layer_factory.cpp.(也可以自己创建一个宏,然后模仿lay_factory.cpp中GetConvolutionLayer)

6.Write tests in test/test_your_layer.cpp. Use test/test_gradient_check_util.hpp to check that your Forward and Backward implementations are in numerical agreement.
caffe/src/caffe/test/test_spp_layer.cpp
可以尝试测试一下前向和后向传播是否正确。

至此,可以确认caffe上已经提供了关于spp的CPU实现,可以尝试一个直接在caffe框架中的spp_net网络。比如用zf-5或者convnet*-5在voc 2007数据集上的测试。



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值