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

来源:互联网 发布:嘉兴学院客户端mac 编辑:程序博客网 时间:2024/06/05 05:55

前一篇文章介绍了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代表了他们编码之后的顺序,小号在前,大号在后。

最近一周会更新完毕!!

0 0
原创粉丝点击