A Discriminative Feature Learning Approach for Deep Face Recognition 的源码部分分析

前一篇文章介绍了centerloss的训练过程,以及结果。本文分析一下CenterLoss的源码部分。同时这也是在caffe中添加新的一层的方法。(本文时特例添加loss层)

宏观感受

先来看看作者对一个刚从github上拉下来的caffe做了哪些改动。

这里写图片描述

step1: 修改caffe.proto

vim caffe/src/caffe/proto/caffe.proto
图为未修改之前LayerParameter的配置

这里写图片描述

 // 1-修改如下注释
 //Update the next available ID when you add a new LayerParameter field

 //LayerParameter next available layer-specific ID: 148 (last added: center_loss_param)
 //其中148 这个数字得注意。 caffe的LayerParameter中新定义下一个变量的ID:147. 我们新加入一个变量后,下一个新加入的变量ID:148.

 // 2-添加如下代码 在LayerParameter中
 optional CenterLossParameter center_loss_param = 147;

 // 3-在caffe.proto 最末尾添加自己定义层

message CenterLossParameter {
  optional uint32 num_output = 1; // The number of outputs for the layer
  optional FillerParameter center_filler = 2; // The filler for the centers
  optional int32 axis = 3 [default = 1]; //default = 1 相当于c++总的缺省初始化值。 
}                
/* 标签数字1和2,3表示不同的字段在序列化后的二进制数据中的布局位置。在该例中,center_filler字段编码后的数据一定位于num_output后。需要注意的是该值在同一message中不能重复。*/
// 说白了,1,2,3代表了他们编码之后的顺序,小号在前,大号在后。

最近一周会更新完毕!!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值