GIoU

本文深入探讨GIoU损失函数,包括其定义、参数作用,如原始损失、权重系数和贡献比例调节等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    def bbox_giou(self, boxes1, boxes2):

        boxes1 = tf.concat([boxes1[..., :2] - boxes1[..., 2:] * 0.5,
                            boxes1[..., :2] + boxes1[..., 2:] * 0.5], axis=-1)
        boxes2 = tf.concat([boxes2[..., :2] - boxes2[..., 2:] * 0.5,
                            boxes2[..., :2] + boxes2[..., 2:] * 0.5], axis=-1)

        boxes1 = tf.concat([tf.minimum(boxes1[..., :2], boxes1[..., 2:]),
                            tf.maximum(boxes1[..., :2], boxes1[..., 2:])], axis=-1)
        boxes2 = tf.concat([tf.minimum(boxes2[..., :2], boxes2[..., 2:]),
                            tf.maximum(boxes2[..., :2], boxes2[..., 2:])], axis=-1)

        boxes1_area = (boxes1[..., 2] - boxes1[..., 0]) * (boxes1[..., 3] - boxes1[..., 1])
        boxes2_area = (boxes2[..., 2] - boxes2[..., 0]) * (boxes2[..., 3] - boxes2[..., 1])

        left_up = tf.maximum(boxes1[..., :2], boxes2[..., :2])
        right_down = tf.minimum(boxes1[..., 2:], boxes2[..., 2:])

        inter_section = tf.maximum(right_down - left_up, 0.0)
        inter_area = inter_section[..., 0] * inter_section[..., 1]
        union_area = boxes1_area + boxes2_area - inter_area
        iou = inter_area / union_area

        enclose_left_up = tf.minimum(boxes1[..., :2], boxes2[..., :2])
        enclose_right_down = tf.maximum(boxes1[..., 2:], boxes2[..., 2:])
        enclose = tf.maximum(enclose_right_down - enclose_left_up, 0.0)
        enclose_area = enclose[..., 0] * enclose[..., 1]
        giou = iou - 1.0 * (enclose_area - union_area) / enclose_area

        return giou

Define {\color{red}p_t}

p_{t}=\left $$\begin{cases} p& \text {if\;y=1} \\ {1-p}& \text{otherwise} \end{cases}$$ \right.\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\,\tag(1)

CE(p_{t})=-\log(p_{t})=\left $$\begin{cases} -\log{p}& \text {if\;y=1} \\ -\log{(1-p)}& \text{otherwise} \end{cases}$$ \right.\qquad\qquad\qquad\qquad\qquad\qquad\;\,\,\;\;\,\,\tag(2)

FL(p_{t})&=-\alpha_{t}(1-p_{t})^\gamma\log(p_{t})&=-\alpha_{t}\beta_{t}^{\text{gamma}}\log(p_{t})\qquad\qquad\qquad\qquad\qquad\quad\quad\,\;\;\;\;\;\tag(3)

这里

\beta_{t}=1-p_{t}\qquad\qquad\qquad\qquad\qquad\qquad\quad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad\;\;\;\;\,\,\,\,\,\,\,\,\;\tag(4)     

\alpha_{t} = \text{alpha}*\text{target}+ {(1-\text{alpha})}*\text{target}\qquad\qquad\qquad\qquad\qquad\quad\qquad\qquad\;\;\;\;\,\,\,\,\,\,\,\,\;\,\,\;\,\tag(5)

\beta_{t} = (1-p_{t})*\text{target}+ p_{t}*\text{target}\qquad\qquad\qquad\qquad\qquad\quad\quad\quad\quad\quad\qquad\quad\;\,\,\,\;\;\;\;\,\,\,\,\,\,\,\,\;\,\;\,\tag(6)

-\log({p_{t}})表示原始损失函数;

alpha表示正样本采用的权重;

beta表示正样本对loss的贡献;

gamma表示正、负样本对loss贡献的调节系数。

 

           

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值