caffe添加层:Focal Loss的caffe实现
版權(quán)聲明:本文為博主原創(chuàng)文章,轉(zhuǎn)載請注明出處,謝謝。?? ?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?
版權(quán)聲明:本文為博主原創(chuàng)文章,轉(zhuǎn)載請附上博文鏈接!
總結(jié)
以上是生活随笔為你收集整理的caffe添加层:Focal Loss的caffe实现的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Object Detection(目标检
- 下一篇: FocalLoss的Caffe复现版