l = parse_detection(options, params)

29 篇文章 1 订阅
27 篇文章 2 订阅

l = parse_detection(options, params);函数主体

detection_layer parse_detection(list *options, size_params params)
{
    int coords = option_find_int(options, "coords", 1);//设置位置损失项前缀因子参数
    int classes = option_find_int(options, "classes", 1);//设置类别
    int rescore = option_find_int(options, "rescore", 0);//设置得分
    int num = option_find_int(options, "num", 1);//设置框的数量
    int side = option_find_int(options, "side", 7);//设置划分网格数side*side
    detection_layer layer = make_detection_layer(params.batch, params.inputs, num, side, classes, coords, rescore);

    layer.softmax = option_find_int(options, "softmax", 0);
    layer.sqrt = option_find_int(options, "sqrt", 0);

    layer.max_boxes = option_find_int_quiet(options, "max",90);
    layer.coord_scale = option_find_float(options, "coord_scale", 1);
    layer.forced = option_find_int(options, "forced", 0);
    layer.object_scale = option_find_float(options, "object_scale", 1);
    layer.noobject_scale = option_find_float(options, "noobject_scale", 1);
    layer.class_scale = option_find_float(options, "class_scale", 1);
    layer.jitter = option_find_float(options, "jitter", .2);
    layer.random = option_find_int_quiet(options, "random", 0);
    layer.reorg = option_find_int_quiet(options, "reorg", 0);
    return layer;
}

detection_layer layer = make_detection_layer(params.batch, params.inputs, num, side, classes, coords, rescore);

detection_layer make_detection_layer(int batch, int inputs, int n, int side, int classes, int coords, int rescore)
{
	//设置网络参数
    detection_layer l = {0};
    l.type = DETECTION;

    l.n = n;
    l.batch = batch;
    l.inputs = inputs;
    l.classes = classes;
    l.coords = coords;
    l.rescore = rescore;
    l.side = side;
    l.w = side;
    l.h = side;
    assert(side*side*((1 + l.coords)*l.n + l.classes) == inputs);//判断s*s*(num*(4+1)+classes)是否等于输入
    l.cost = calloc(1, sizeof(float));//为损失数据分配空间
    l.outputs = l.inputs;//输出等于输入,yolo1即l.side*l.side*(num*(1+l.coords)+l.classes)
    l.truths = l.side*l.side*(1+l.coords+l.classes);//设置标签,例如yolo1为7x7x(1+4+20),因为一个网格只有一个标签
    l.output = calloc(batch*l.outputs, sizeof(float));//为min_batch所有的输出分配空间
    l.delta = calloc(batch*l.outputs, sizeof(float));

    l.forward = forward_detection_layer;//为函数指针设置指向函数入口地址
    l.backward = backward_detection_layer;
#ifdef GPU//若是定义了则运行下面代码,功能与上面相同
    l.forward_gpu = forward_detection_layer_gpu;
    l.backward_gpu = backward_detection_layer_gpu;
    l.output_gpu = cuda_make_array(l.output, batch*l.outputs);
    l.delta_gpu = cuda_make_array(l.delta, batch*l.outputs);
#endif

    fprintf(stderr, "Detection Layer\n");
    srand(0);

    return l;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值