windows caffe添加新层center loss layer

相关文件可见:https://github.com/ydwen/caffe-face

主要包括4个步骤:

(1)src\caffe\caffe.proto里添加消息机制:proto格式的ID号(要求ID号唯一,不与其他ID重合即可)及相应定义

         在message LayerParameter{}中添加如下ID号:
         optional CenterLossParameter center_loss_param = 155;

         再在文档最后加入:
         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];  
      }

(2)include/caffe/layers/添加头文件center_loss_layers.hpp

(3)src/caffe/layers/添加CPU、GPU实现的相关文件center_loss_layers.cpp\center_loss_layers.cu

(4)重新编译Caffe。首先在windows/libcaffe/libcaffe.vcxproj和libcaffe.vcxproj.filters里

        libcaffe.vcxproj相应处增加:   

       <ClCompile Include="..\..\src\caffe\layers\center_loss_layer.cpp" />

       <ClInclude Include="..\..\include\caffe\layers\center_loss_layer.hpp" />

       <CudaCompile Include="..\..\src\caffe\layers\center_loss_layer.cu" />

       libcaffe.vcxproj相应处增加:

       <ClCompile Include="..\..\src\caffe\layers\center_loss_layer.cpp">
        <Filter>src\layers</Filter>
       </ClCompile>

       <ClInclude Include="..\..\include\caffe\layers\center_loss_layer.hpp">
        <Filter>include\layers</Filter>
       </ClInclude>

       <CudaCompile Include="..\..\src\caffe\layers\center_loss_layer.cu">
        <Filter>cu\layers</Filter>
       </CudaCompile>

 

再重新编译。成功即可使用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值