如何向caffe中添加层

修改caffe\src\caffe\proto\caffe.proto

在最后添加centerloss层的参数信息

 

message CenterLossParameter {
optional uint32 num_output = 1; // The number of outputs for the layer
optional FillerParameter center_filler = 2; // The filler for the centers
// The first axis to be lumped into a single inner product computation;
// all preceding axes are retained in the output.
// May be negative to index from the end (e.g., -1 for the last axis).
optional int32 axis = 3 [default = 1];
}

 

添加层类型信息,注意不能与其他层的数字相同。

 

optional CenterLossParameter center_loss_param = 148;

将cpu和gpu两个模式下运行的文件添加到src\caffe\layers\

如何编写层,请查看官方文档或者谷歌

3.添加层的头文件

向\include\caffe\layers\中添加头文件

 然后编译的命令和正常的不一样

cp Makefile.config.examples Makefile.config

vim Makefile.config
make -j8
make pycaffe
make distribute

4.修改bashrc

在最后加入:

PYTHONPATH=$/home/lester/caffe-bak/distribute/python:$PYTHONPATH
export PATH=/home/lester/caffe-bak/build/tools:$PATH
LD_LIBRARY_PATH=$/home/lester/caffe-bak/build/lib:$LD_LIBRARY_PATH

source ~/.bashrc

sudo vim /etc/profile

在最后加入:

export PYTHONPATH=/home/lester/caffe-bak/python:$PYTHONPATH

source /etc/profile

 

转载于:https://www.cnblogs.com/HugoLester/p/7206319.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值