yolov2 损失函数_yolo v2 损失函数源码解读

region_layer.c

box get_region_box(float *x, float *biases, int n, int index, int i, int j, int w, int h, int stride)

{

box b;

b.x = (i + x[index + 0*stride]) / w;

b.y = (j + x[index + 1*stride]) / h;

b.w = exp(x[index + 2*stride]) * biases[2*n]   / w;

b.h = exp(x[index + 3*stride]) * biases[2*n+1] / h;

//printf("%f/%d/%d - %f/%f/%f/%f\n", x[index + 2*stride], w, h, b.x, b.y, b.w, b.h);

return b;

}

float delta_region_box(box truth, float *x, float *biases, int n, int index, int i, int j, int w, int h, float *delta, float scale, int stride)

{

box pred = get_region_box(x, biases, n, index, i, j, w, h, stride);

float iou = box_iou(pred, truth);

float tx = (truth.x*w - i);

float ty = (truth.y*h - j);

float tw = log(truth.w*w / biases[2*n]);

float th = log(truth.h*h / biases[2*n + 1]);

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;

}

void forward_region_layer()

{

...

for (b = 0; b 

if(l.softmax_tree){

// 没执行

}

// 下面的 for 循环是计算没有物体的 box 的 confidence 的 loss

// 1, 遍历所有格子以及每个格子的 box,计算每个 box 与真实 box 的 best_iou

// 2, 先不管三七二十一,把该 box 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值