YOLOV3-损失函数及其源代码理解

YOLOV3-损失函数及其源代码理解(yolo_layer.c)

讲得好
https://github.com/AlexeyAB/darknet/issues/821

x,y,w,h 损失

原版的bbox损失为MSE,其后又GIOU,DIOU…
delta即为求完损失的梯度
公式对应图
在这里插入图片描述
在这里插入图片描述
思路及具体求法:
https://github.com/AlexeyAB/darknet/issues/2287
https://blog.csdn.net/qq_34199326/article/details/84109828
>https://blog.csdn.net/qq_34199326/article/details/84109828

float delta_yolo_box(box truth, float *x, float *biases, int n, int index, int i, int j, int lw, int lh, int w, int h, float *delta, float scale, int stride)
{
    box pred = get_yolo_box(x, biases, n, index, i, j, lw, lh, w, h, stride);
    float iou = box_iou(pred, truth); 
    float tx = (truth.x*lw - i); 
    float ty = (truth.y*lh - j); 
    float tw = log(truth.w*w / biases[2*n]); 
    float th = log(truth.h*h / biases[2*n + 1]);
    scale = 2 - groundtruth.w * groundtruth.h  //关于这个为什么相等的问题,总得来说就是为了小目标delta可以大一些。可以参看https://github.com/AlexeyAB/darknet/issues/1532
    delta[index + 0*stride] = scale * (tx - x[index + 0*stride]); 
    delta[index + 1*stride] = scale * (ty - x[index + 1*stride]);
    delta[index + 2*stride] = scale * (tw - x[index + 2*stride]);
    delta[index + 3*stride] = scale * (th - x[index + 3*stride]);
    return iou;
}

类别损失

讲的好
https://github.com/AlexeyAB/darknet/issues/1695

置信度损失

在这里插入图片描述在这里插入图片描述

总损失

看完链接基本就都明白了

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值