赞
踩
版权声明:本文为博主原创文章,转载请注明出处,谢谢。 https://blog.csdn.net/wfei101/article/details/79477542
原代码见:
https://github.com/chuanqi305/FocalLoss
1,caffe.proto
源文件在src/caffe/proto/目录里
从492行这些optional里,作者添加了两行:
optional ReLU6Parameter relu6_param = 208;
optional FocalLossParameter focal_loss_param = 147;
从895行这里添加了一行:
optional bool half_pad = 19 [default = false];
从1425行这里添加一行:
optional bool reduce_boxes = 14 [default = false];
从1505行添加了一段:
message ReLU6Parameter{
enum Engine {
DEFAULT = 0;
CAFEE = 1;
CUDNN = 2;
}
optional Engine engine = 2[default = DEFAULT];
}
从1641行添加一段:
message FocalLossParameter{
enum Engine{
DEFAULT = 0;
CAFFE = 1;
CUDNN = 2;
}
optional Engine engine = 1[default = DEFAULT];
//The axis along which to perform the softmax -- may be negative to index
//from the end(e.g., -1 for the last axis).
//Any other axes will be evaluated as independent softmaxes.
optional int32 axis = 2[default = 1];
optional float alpha = 3[default = 0.25];
optional float gamma = 4[default = 2.0];
}
2.在src/caffe/layers/下放入focal_loss_layer.cpp和focal_loss_layer.cu文件
3.在include/caffe/layers/下放入focla_loss_layer.hpp和multibox_focal_loss_layer.hpp
4. 修改prototxt:只需要修改一下层名
layer {
name: "mbox_loss"
type: "MultiBoxFocalLoss" #change the type
bottom: "mbox_loc"
bottom: "mbox_conf"
bottom: "mbox_priorbox"
bottom: "label"
top: "mbox_loss"
include {
phase: TRAIN
}
propagate_down: true
propagate_down: true
propagate_down: false
propagate_down: false
loss_param {
normalization: VALID
}
focal_loss_param { #set the alpha and gamma, default is alpha=0.25, gamma=2.0
alpha: 0.25
gamma: 2.0
}
multibox_loss_param {
loc_loss_type: SMOOTH_L1
conf_loss_type: SOFTMAX
loc_weight: 1.0
num_classes: 2
share_location: true
match_type: PER_PREDICTION
overlap_threshold: 0.5
use_prior_for_matching: true
background_label_id: 0
use_difficult_gt: true
neg_pos_ratio: 3.0
neg_overlap: 0.5
code_type: CENTER_SIZE
ignore_cross_boundary_bbox: false
mining_type: NONE #do not use OHEM
}
}
重新编译Caffe
---------------------
作者:BigCowPeking
来源:CSDN
原文:https://blog.csdn.net/wfei101/article/details/79477542
版权声明:本文为博主原创文章,转载请附上博文链接!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。