caffe添加新的层

新版的caffe和旧版caffe稍微有些不同,旧版caffe需要改/src/caffe/layer_factory.cpp,新版则不需要。可参考

首先,修改caffe.proto

在caffe.proto文件中的message LayerParameter { } 中添加:

optional MylayerParameter mylayer_param = ID2;

下面以添加3D卷积层为例:optional Convolution3DParameter convolution3d_param = 149;
卷积层要定义自己的参数,要添加L:

message Convolution3DParameter {
  optional uint32 num_output = 1; // The number of outputs for the layer
  optional bool bias_term = 2 [default = true]; // whether to have bias terms
  optional uint32 pad = 3 [default = 0]; // The padding size
  optional uint32 kernel_size = 4; // The kernel size
  optional uint32 group = 5 [default = 1]; // The group size for group conv
  optional uint32 kernel_depth = 6; // The kernel size
  optional uint32 stride = 7 [default = 1]; // The stride
  optional uint32 temporal_stride = 8 [default = 1]; // The stride for temporal
  optional FillerParameter weight_filler = 9; // The filler for the weight
  optional FillerParameter bias_filler = 10; // The filler for the bias
  optional uint32 filter_group = 11 [default = 1]; // divide filters into groups to reduce memory consumption
  optional uint32 temporal_pad = 12 [default = 0]; // padding size for temporal
}

添加头文件和源文件

头文件和源文件直接从C3D获取,头文件放在/include/caffe/layers中,源文件放在/src/caffe/layers中,如果用到cuda要编写cu文件。

添加测试文件

在/src/caffe/test中添加测试文件,测试文件并不是必须添加的。
这些都完事后重新编译caffe。
主要参考这位同学.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值